开发者

Unitize the columns of matrix

开发者 https://www.devze.com 2023-03-23 17:13 出处:网络
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)

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消