normalise a column in a matrix
Afficher commentaires plus anciens
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.
Réponses (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 commentaires
Fadi Lama
le 6 Déc 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)
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!