extracting a row from a matrix
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mahi Nazir
am 12 Dez. 2013
Kommentiert: Mahi Nazir
am 12 Dez. 2013
I want to extract a row from a matrix for which the last column element is largest. for example if my matrix is
1 2 3
1 1 4
2 1 2
3 2 5
my answer would be the last row 3 2 5 because 5 is the largest element in the last column. How do I do this please help.
0 Kommentare
Akzeptierte Antwort
Jan
am 12 Dez. 2013
M = [1,2,3;1,1,4;2,1,2;3,2,5];
[~, max_idx] = max( M(:,end) );
max_row = M(max_idx,:);
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices 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!