% MATLAB script: normalized orthogonal projection
v = [3;0.4]; w = [3;0.400001];    % the vectors
z = w - (dot(v,w)/dot(v,v))*v,% orthogonal projection of w onto v
z = z/norm(z),                 % \emph{normalize} vector 
dot(v,z), % Test for orthogonality