finding minimum value of certain row of matrix with condition
Ältere Kommentare anzeigen
i have matrix [6,6], how to find minimum value at certain row eg what is the minimum value that >0, at row 1?
r=[0.00 18.68 39.62 20.81 5.39 39.92
18.68 0.00 33.84 38.91 24.04 53.41
39.62 33.84 0.00 48.38 42.20 45.12
20.81 38.91 48.38 0.00 15.62 25.08
5.39 24.04 42.20 15.62 0.00 36.40
39.92 53.41 45.12 25.08 36.40 0.00];
Then the result is 5.39 in [1 5], it will loop to continued to find the min value at other row, the next row searching on the min value is based on the previous result of the column. eg 2nd result is 15.62 [5 4]
2 Kommentare
Mohammad Abouali
am 15 Okt. 2014
what would be the third result? you jumped from row 1 to row 5. The result in row one was 5.39 and the first element in row 5 is 5.39. But now the result is 15.62 but there is no row with 15.62 as the first value. so what would be the third result? or do you stop here.
Akzeptierte Antwort
Weitere Antworten (1)
Sean de Wolski
am 15 Okt. 2014
Replace the zeros with Infs and take the min:
r2 = r;
r2(r2==0) = inf;
min(r2,[],2)
Kategorien
Mehr zu Mathematics and Optimization finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!