I have a matrix not a vector and I need the minimum value except 0 and position of minimum value in each row
help how can I find the minimum number and return it's index in each row?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
maha ismail
am 13 Nov. 2014
Kommentiert: maha ismail
am 13 Nov. 2014
help how can I find the minimum number and return it's index in each row?
Akzeptierte Antwort
Manoj
am 13 Nov. 2014
a=[8,2,3,4,5];
[b,ix]=min(a);
ix gives you the positions and b gives the minimum value
4 Kommentare
Weitere Antworten (1)
Guillaume
am 13 Nov. 2014
To find the minimum of a row, use:
min(m, [], 2)
Probably, the simplest way to ignore 0s is to replace them with NaNs before calling min.
m(m == 0) = nan;
[mval, mcol] = min(m, [], 2);
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!