title: How to calculate Euclidean length of a matrix without loops?
body: <p>It seems like the answer to this should be simple, but I am stumped.  I have a matrix of Nx3 matrix where there 1st 2nd and 3rd columns are the X Y  and Z coordinates of the nth item.  I want to calculate the distance from the origin to the item.  In a non vectorized form this is easy.</p>
  
  <p>distance = norm([x y z]);</p>
  
  <p>or </p>
  
  <p>distance = sqrt(x^2+y^2+z^2);</p>
  
  <p>However, in vectorized form its not so simple.  When you pass a matrix to norm it no longer returns the Euclidean length.</p>
  
  <p>distance = norm(matrix);  %doesn't work</p>
  
  <p>and </p>
  
  <p>distance = sqrt(x(:,1).*x(:,1)+y(:,2).*y(:,2)+z(:,3).*z(:,3)); %just seems messy</p>
  
  <p>Is there a better way to do this?</p>