How could normalize a matrix between 0 and 1.
Mostra commenti meno recenti
I have a matrix 14x15536 how it shows in the picture, and i would like to normalize each row between 0 and 1.
How could I do it??
Thanks in advance.

Risposte (2)
Stephan
il 2 Mag 2019
1 voto
result = normalize(x,2,'range')
11 Commenti
Stephan
il 2 Mag 2019
Which release do you use?
Edu Gomez
il 2 Mag 2019
Edu Gomez
il 2 Mag 2019
I dont think that you can say it is correct to set this equal to one. It would also not be correct to set it to zero. You do a division of zero by zero - this leads to a NaN value. However, the inbuilt normalize function treats this with setting the values equal to zero.
Adam
il 2 Mag 2019
You can do it in vectorised form without the need of a for loop as:
rowMin = min( x, [], 2 );
result = ( x - rowMin ) ./ ( max( x, [], 2 ) - rowMin );
You will still get the same divide by 0 problem though if you have a constant row because you could 'normalise' it to any value between 0 and 1 equally so you have to just majke a choice depending on your usage.
Edu Gomez
il 3 Mag 2019
Adam
il 3 Mag 2019
./ is point-wise division rather than matrix division
Stephen23
il 3 Mag 2019
"And one more question, whats means " ./ " ????"
Edu Gomez uses R2015a, so no auto-expanding, which was introduced in R2016b. Then bsxfun is required:
rowMin = min(x, [], 2);
result = bsxfun(@minus, x, rowMin) ./ bsxfun(@minus, max(x, [], 2), rowMin);
Edu Gomez
il 3 Mag 2019
0 voti
Categorie
Scopri di più su Sparse Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
