How to calculate Euclidean length of a matrix without loops?
Try this:
>> xyz = [1 2 3; 4 5 6; 7 8 9; 2 8 4] xyz = 1 2 3 4 5 6 7 8 9 2 8 4 >> distance = sqrt(sum(xyz.^2, 2)) distance = 3.74165738677394 8.77496438739212 13.9283882771841 9.16515138991168
Yes, there is.
distance = sqrt(sum(matrix.^2,2)); %# matrix is [x y z]