How to normalize data of each row of Matrix A=[10 20 30 40;5 15 25 30]; between 0 and 1?

1 vue (au cours des 30 derniers jours)
nomi nomi
nomi nomi le 29 Avr 2020
Modifié(e) : nomi nomi le 29 Avr 2020
I am new to MATLAB coding. I want to normalize each value of every row and have write the following code
A=[10 20 30 40;5 15 25 30];
for n=1:2
[valMax,locMax] =max(A(n,:));
[valMin,locMin] =min(A(n,:));
divideOn=A(n,:)-valMin;
divideBy=valMax - valMin;
A(n,:)=divideOn/divideBy;
end
This code is coverting value of each row between 0 and 1.Kindly guide is this right approach.

Réponses (1)

Akira Agata
Akira Agata le 29 Avr 2020
I believe you can do this task by simply applying normalize function, like:
B = normalize(A,2,'range'); % Normalize each row to [0 1] range

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by