Normalizing to the maximum value

I have a 48X128 matrix. I want to normalize each row to the maximum value in that row. What function will achieve this?

Antworten (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov am 3 Feb. 2023
Bearbeitet: Sulaymon Eshkabilov am 3 Feb. 2023

0 Stimmen

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 Kommentar

Star Strider
Star Strider am 3 Feb. 2023
the normalize function defaults to normalising by 'zscore' . For other options, see the documentation section on method.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2022b

Gefragt:

am 3 Feb. 2023

Kommentiert:

am 3 Feb. 2023

Community Treasure Hunt

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

Start Hunting!

Translated by