%
% Example macro about projecting one vector to another.
% TK 14.11.02
%
clear; close all;
xo = zeros(1,2); yo = xo;
u1 = [3 1]; u2 = [1 1];
quiver(xo,yo,u1,u2,0,'b');
set(gca,'XLim',[-0.5 5],'YLim',[-0.5 2]);
%
u1d = u1/norm(u1);
u1p = (u2*u1d')*u1d;
xl = [xo(1) 5*u1p(1)]; yl = [xo(2) 5*u1p(2)]; 
ul1 = [u2(1) u1p(1)]; ul2 = [u2(2) u1p(2)]; 
hold on
plot(xl,yl,'b--')
plot(ul1,ul2,'r--')
quiver(xo(1),xo(2),u1p(1),u1p(2),0,'r')
grid on, axis equal
hold off
