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

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -