matlab - Calculating the norm of each row in a matrix -


this question has answer here:

i have nx3 matrix (a) columns x,y,z respectively. want calculate norm sqrt(x^2+y^2+z^2) each row. did loop that:

for = 1:length(a) result(i) = norm(a(i,:)) end 

is there other way avoiding loop?

thanks

you can this:

sqrt(sum(a.^2, 2)) 

your method returns 1x3 returns 3x1. if want can transpose doubt need to.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -