normalise a column in a matrix
显示 更早的评论
I have a 5x10 matrix of non-zero values. How can I normalise the 9'th column and make all its values equal to 1.
回答(1 个)
Normalize and making all its values equal 1 are two different, non-equivalent processes.
Assuming you want to set all values to 1, something like this should work:
% Create 5x10 matrix
m=rand(5,10);
% Set all values in the 9th column equal to 1
m(:,9)=1
2 个评论
Fadi Lama
2020-12-6
Ok, but the effect would be the same, right?
Divide column 9 by itself.
% Create 5x10 matrix
m=rand(5,10);
% Normalize each value in column 9 by dividing by itself
m(:,9)=m(:,9)./m(:,9)
btw, normalizing each row by the value that is in its column 9 is just as easy
m2=rand(5,10);
m2=m2./m2(:,9)
类别
在 帮助中心 和 File Exchange 中查找有关 Mathematics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!