%Copied from elements from electromagetics
% 2 vectors find dot, cross, sum, and difference
vA =input('Enter vector A in form [a b c]\n');
if isempty(vA); vA= [0 0 0]; end
vB =input('Enter vector B in form [a b c]\n');
if isempty(vB); vB= [0 0 0]; end
disp('Magnitude of A:')
disp(norm(vA))
%norm: finds the magnitude of a, multi-dimention vector
disp('Magnitude of B:')
disp(norm(vB))
disp('Unit Vector in the direction of A:')
disp(vA/norm(vA))
%unit vector is the vector divided by its magnitude
disp('Unit vector in direction of B:')
disp(vB/norm(vB))
disp('Sum A+B:')
disp(vA+vB)
disp('Difference A, B')
disp(vA-vB)
disp('Dot product A.B:')
disp(dot(vA,vB))
disp('Cross')
disp(cross(vA,vB))
v=[vB;vA];
%This scipt will point out the points and draw a
%line between them
%use grid to show the line
%use grid to show the line
plot3(v(:,1),v(:,2),v(:,3),'r'),grid, hold on;
plot3(0.2,0.3,4,'ro'),grid, hold on;
plot3(-0.3,0.3,0.1,'ro'),grid;