Effacer les filtres
Effacer les filtres

Normalizing to the maximum value

50 vues (au cours des 30 derniers jours)
Anwesh Saha
Anwesh Saha le 3 Fév 2023
Commenté : Star Strider le 3 Fév 2023
I have a 48X128 matrix. I want to normalize each row to the maximum value in that row. What function will achieve this?

Réponses (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 3 Fév 2023
Modifié(e) : Sulaymon Eshkabilov le 3 Fév 2023
Use normalize() to normalize each row or use simple matrix operation to obtain the values of matrix elements to be between [0 .. 1]:
A = randi(10, 7 , 5) % Data
A = 7×5
8 8 2 7 10 3 2 9 10 7 2 10 1 6 10 2 2 10 5 6 8 9 7 5 8 2 3 9 3 8 2 7 3 6 10
An = normalize(A,2) % Normalize each row
An = 7×5
0.3333 0.3333 -1.6667 0 1.0000 -0.8979 -1.1785 0.7857 1.0663 0.2245 -0.8907 0.9845 -1.1251 0.0469 0.9845 -0.9045 -0.9045 1.5076 0 0.3015 0.3956 1.0550 -0.2638 -1.5825 0.3956 -0.9258 -0.6172 1.2344 -0.6172 0.9258 -1.1217 0.4362 -0.8101 0.1246 1.3710
ANor = A./max(A(1:end,:)) % Normalize wi.r.t. max value of each row
ANor = 7×5
1.0000 0.8000 0.2000 0.7000 1.0000 0.3750 0.2000 0.9000 1.0000 0.7000 0.2500 1.0000 0.1000 0.6000 1.0000 0.2500 0.2000 1.0000 0.5000 0.6000 1.0000 0.9000 0.7000 0.5000 0.8000 0.2500 0.3000 0.9000 0.3000 0.8000 0.2500 0.7000 0.3000 0.6000 1.0000
  1 commentaire
Star Strider
Star Strider le 3 Fév 2023
the normalize function defaults to normalising by 'zscore' . For other options, see the documentation section on method.

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by