https://github.com/elifesciences-publications/General
Raw File
Tip revision: 42973d0a7a7d079d677ad4e18d9d29d4ceb774b4 authored by editorialelife on 23 May 2018, 15:45:52 UTC
Update README.md
Tip revision: 42973d0
proj.m
function [v_proj] = proj(v,u)
% PROJ
% [v_proj] = proj(v,u)
% Generates a vector, v_proj that is obtained by orthogonally projecting
% the vector v onto the unit vector u
% If u is not a unit vector then it converts it into one
% Author: AP
if sqrt(sum(u.^2))>1
    u=unitvec(u);
end
v_proj = dot(v,u)*u;
if size (v_proj,2) > 1 
    v_proj = v_proj'
end
back to top