Given a matrix d x n (d-dimensional, n-object) I开发者_开发问答 would like to compute the unit length vector of each columns. (i.e the resultant matrix should have unit length in every column)
how can i do it without looping every column?
I'm assuming you're using the L2 norm. In that case,
normalizedVector = bsxfun(@rdivide,vector,sqrt(sum(vector.^2,1)));
will have unit length along each column.
精彩评论