小编Lui*_*uis的帖子

将矩阵列转换为单位向量的快速方法

我有一个矩阵:

S = [  -1.0400    4.9100    4.1000   -3.5450   -0.6600   -0.9300    4.3950   -1.0650    2.9850   -4.9800    0.2100;
   -0.5200   -4.3150   -3.0950    0.5700    4.4700    1.1500    3.1350    0.6450    0.3750   -4.9150   -2.1150; 
    5.0000    5.0000    5.0000    5.0000    5.0000    5.0000    5.0000    5.0000    5.0000    5.0000    5.0000 ];
Run Code Online (Sandbox Code Playgroud)

我想将列转换为单位向量,所以我使用for循环

for i=1:size(S,2)
    S(:,i) = S(:,i) / norm( S(:,i) );
end
Run Code Online (Sandbox Code Playgroud)

有没有办法在MATLAB中更有效地完成这项工作?

optimization performance matlab normalize matrix

1
推荐指数
1
解决办法
97
查看次数

标签 统计

matlab ×1

matrix ×1

normalize ×1

optimization ×1

performance ×1