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!