normalise a column in a matrix
Show older comments
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.
Answers (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 Comments
Fadi Lama
on 6 Dec 2020
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)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!