I have got a matrix Nx3 dimension in matlab. I want to calculate the norm of every n-th row of the matrix. However I want to perform the norm calculation without using for loop. Is there a way to do so? My for loop code:
for i=1:length(accelerometer)
magnitude(i,:) = sqrt(accelerometer(i,1)^2 + accelerometer(i,2)^2+ accelerometer(i,3)^2);
end
Let
Abe your matrix.If "every n-th row" means rows
1,n+1,2*n+1,...:If it simply means "every row":
In either case, if
Ais real you can removeabs.