find second minimum in a row in matlab without sorting
55 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nitin Sapre
am 16 Okt. 2019
Bearbeitet: Adam Danz
am 21 Okt. 2019
find second minimum in a row in matlab without sorting.
excluding zero
example A = [ 3.5 2 1.6 1.456 0 1.9 2.6 ; 3.8 2.6 3.9 0 6 1.564 0 ]
3 Kommentare
Akzeptierte Antwort
Nitin Sapre
am 19 Okt. 2019
4 Kommentare
Adam Danz
am 21 Okt. 2019
Bearbeitet: Adam Danz
am 21 Okt. 2019
"Any kind of help ffrom your side will be appreciate"
If you have any questions about the other answers that were recommended here, please let us know. I've addapted both answers to your needs in my comment above.
Sorting may be an even better approach and it's still not clear why sorting is off the table.
An accepted answer is a sign to inexperienced users that an answer is the best solution which clearly isn't the case here. This is why you are being urged to reconsider the other options.
Weitere Antworten (2)
Ekaterina Sadovaya
am 18 Okt. 2019
You can exclude the first minimum. So, for example for the first row it will be
A1 = A(1,:);
[first_min_value, index] = min(A1);
A1(index) = [];
second_min_value = min(A1);
7 Kommentare
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!