norm function in for loop in Matlab -
is there way write below code in matlab without loop?
for g=1:nn u(g)=uu(g)/norm(uu(g),vv(g)); v(g)=vv(g)/norm(uu(g),vv(g)); end
if vector, can point division:
mat = [uu.' vv.']; norms = arrayfun(@(idx)norm(mat(idx,:)),1:length(uu)); % post https://www.mathworks.com/matlabcentral/newsreader/view_thread/172116 %or instead norms = sqrt(uu.^2 + vv.^2); u = uu ./ norms; v = vv ./ norms;
Comments
Post a Comment