%Purpose: Caculate the magnitude of the vector and rotate it along the z 
%           axis
%Author:Guofeng Yuan
%Date:02/04/2010


%the vector
clear;
clc;
a=[0,0,0];
b=[1,2,3];
%The magnitude of the vector
mag1=norm(b);
%Draw the first vector
vectarrow(a,b,'red');
hold on;
%Rotation angle
theta=25*pi/180;
%The rotation matrix
A=[cos(theta),sin(theta),0;-sin(theta),cos(theta),0;0,0,1];
c=A*b';
%The vector after rotation
d=c';
mag2=norm(d);
%Draw the second vector
vectarrow(a,d,'blue');
%Add title and legend
leg=legend('Before Rotation','After Rotation');
h=title({'Vector (1,2,3) Rotated Clockwise by 25 degrees about z axis';['The Magnitude of this Vector is ',num2str(mag1),'']});
set(h,'fontsize',18);
set(leg,'fontsize',20);
hold off;

set(gcf,'PaperUnits','inches','PaperPosition',[0 0 12 12])
print -djpeg 'myfig.jpg' -r100
%print -dbmp16m 'myfig.jpg'


