AM.SC.U4CSE24329 MATLAB CALCULUS 2
AM.SC.U4CSE24329 MATLAB CALCULUS 2
v=[2;13];
t=linspace(-30,30,50);
T= meshgrid(t);
X=T*v(1);
Y=T*v(2);
figure;
hold on;
quiver(0,0,v(1),v(2),0,'LineWidth',2,'MaxHeadSize',1000,Color='b');
plot(X,Y,'k.','MarkerSize',10);
xlim([-50,50])
ylim([-50,50])
xlabel("X");
ylabel("Y");
title('span of a vector in 2d');
grid on;
hold off;
%q2
v=[2;13;11];
t=linspace(-30,30,150);
T= meshgrid(t);
X=T*v(1);
Y=T*v(2);
Z=T*v(3);
1
figure;
hold on;
quiver3(0,0,0,v(1),v(2),v(3),0,'LineWidth',2,'MaxHeadSize',1000,Color='b');
plot3(X,Y,Z,'k.','MarkerSize',10);
axis equal;
xlim([-50 50])
ylim([-50 50])
zlim([-50 50])
xlabel("X");
ylabel("Y");
zlabel("Z")
view(3)
title('span of a vector in 3d');
grid on;
hold off;
%q4
v1=[1;0;2]
v1 = 3×1
1
0
2
v2=[1;0;-1]
v2 = 3×1
2
1
0
-1
v=[7;1;1]
v = 3×1
7
1
1
A=[v1,v2];
Av=[A,v];
rank(A);
rank(Av);
if rank(A)==rank(Av)
disp('The vector v belongs to the span of v1 and v2.')
else
disp('The vector v does not belong to the span of v1 and v2.')
end
%q5
v1=[11;50;25]
v1 = 3×1
11
50
25
v2=[1;0;-1]
v2 = 3×1
1
0
-1
v3=[22;32;59]
v3 = 3×1
22
32
59
v=[72;35;11]
v = 3×1
72
35
11
A=[v1,v2,v3];
Av=[A,v];
rank(A);
rank(Av);
if rank(A)==rank(Av)
3
disp('The vector v belongs to the span of v1 and v2.')
else
disp('The vector v does not belong to the span of v1 and v2.')
end
%q6
v1=[2;0;2;3]
v1 = 4×1
2
0
2
3
v2=[2;0;2;4]
v2 = 4×1
2
0
2
4
A=[v1,v2];
rank(A);
if rank(A)==2;
disp('The given vecrots are linearly independent.')
else
disp('The given vectors are linearly dependent.')
end
%q7
v1=[2;0;2;3;5]
v1 = 5×1
2
0
2
3
5
v2=[2;0;2;4;7]
v2 = 5×1
2
0
2
4
7
v3=[10;0;10;17;29]
v3 = 5×1
4
10
0
10
17
29
A=[v1,v2,v3];
rank(A);
if rank(A)==3;
disp('The given vecrots are linearly independent.')
else
disp('The given vectors are linearly dependent.')
end
%q3
v1=[2;3;6];
v2=[1;5;3];
v3=[2;3;6];
v4=[2;5;7];
t=linspace(-30,30,150);
s=linspace(-30,30,150);
[T,S]= meshgrid(t,s);
X=T*v1(1)+S*v2(2);
Y=T*v1(2)+S*v2(2);
Z=T*v1(3)+S*v2(3);
X1=T*v3(1)+S*v4(2);
Y1=T*v3(2)+S*v4(2);
Z1=T*v3(3)+S*v4(3);
figure;
hold on;
quiver3(0,0,0,v1(1),v1(2),v1(3),0,'LineWidth',2,'MaxHeadSize',1000,Color='b');
quiver3(0,0,0,v2(1),v2(2),v2(3),0,'LineWidth',2,'MaxHeadSize',1000,Color='b');
quiver3(0,0,0,v3(1),v3(2),v3(3),0,'LineWidth',2,'MaxHeadSize',1000,Color='b');
quiver3(0,0,0,v4(1),v4(2),v4(3),0,'LineWidth',2,'MaxHeadSize',1000,Color='b');
surf(X,Y,Z, 'FaceAlpha', 0.5, 'EdgeColor', 'blue');
surf(X1,Y1,Z1, 'FaceAlpha', 0.5, 'EdgeColor', 'red');
axis equal;
xlim([-50 50])
ylim([-50 50])
zlim([-50 50])
xlabel("X");
ylabel("Y");
zlabel("Z")
view(3)
title('comparision of span of 2 sets of vectors');
grid on;
hold off;
5
6