row from matrix by argument
1 view (last 30 days)
Show older comments
hi
i have taken an argument from matrix B (the maximun value from column)
now i want to the take the row that the argument is shown in and make from it a vector.
how can i do it ?
thanks
tal shmuel
0 Comments
Accepted Answer
dpb
on 11 Feb 2020
Edited: dpb
on 13 Feb 2020
m=randi(200,4) % sample data
m =
125 95 46 63
118 47 35 185
42 169 46 87
61 39 88 37
The engine:
[~,v]=max(m);
yields
>> v =
1 3 4 2
>>
ADDENDUM:
Ok, latest guess as I thought prior was unlikely...let me try one more time to see if follow...
[~,ix]=max(m(:)); % index of overall maximum in matrix m
[r,c]=ind2sub(size(m),ix); % convert index to row,column location in m
v=m(r,:) % row of m corresponding to that location
result for above sample m is:
>> v =
118 47 35 185
>>
That what you looking for?
4 Comments
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!