Effacer les filtres
Effacer les filtres

Normalization of matrix column

29 vues (au cours des 30 derniers jours)
Danish Nasir
Danish Nasir le 31 Juil 2021
Réponse apportée : Matt J le 31 Juil 2021
I have a matrix say 3x4. I want to normalize each column. Each column has its maximum and minimum value.
i want to use normalization formula in each column as = (value- minimum value of that column)/(maximum value of that column-minimum value of that column).
Hence each column is to be normalized with respect to the minimum and maximum value of that column.
A= [ 1 2 3 4
3 4 5 6
4 5 6 7 ]
In above example column 1 has max value 4 and min value 1. so normalize value of first cell(1,1)=1-1/(4-1). Similarly column 2 has 2 as min and 5 as max value. Also all the final values of the modified matrix should be non negative (-ve value to be made +ve).
Pls provide the code.

Réponses (2)

Matt J
Matt J le 31 Juil 2021
In recent Matlab,
A= [ 1 2 3 4
3 4 5 6
4 5 6 7 ];
A=normalize(A,1,'range')
A = 3×4
0 0 0 0 0.6667 0.6667 0.6667 0.6667 1.0000 1.0000 1.0000 1.0000

Matt J
Matt J le 31 Juil 2021
a=min(A,[],1); b=max(A,[],1);
A=(A-a)./(b-a);

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by