applying norm function to rows of matrix - Matlab

matlab

Solution

What about

 norms = sqrt(sum(A.^2,1))

or

 norms = sqrt(sum(A.^2,2))?

depending on whether your coordinates are in rows or in columns.

Problem

I have a 3 columns, n rows matrix: ``` [ a,b,c; d,e,f; g,h,i; ] ``` I want to apply the norm function to each of the rows, and get a `1xn` matrix containing the norms: ``` [ norm([a,b,c]); norm([d,e,f]); norm([g,h,i]); ] ``` I could do this with a for-loop, but is there a better way?

Original source

Related problems