mag returns the magnitude of a row vector
function [ magnitude ] = mag( vector ) %mag returns the magnitude of a row vector sz=size(vector); if min(sz>1) error('Trying to take the magnitude of a matrix'); end if sz(1)==1 magnitude=sqrt(vector*vector'); end if sz(2)==1 magnitude=sqrt(vector'*vector); end