Find the highest value and its entry of a (2xn) matrix in each column

Hello,
I have a matrix with the size of 2xn , lets fill it with random numbers:
17 23 4 10 11
24 5 6 12 18
Now I want to know the entry number of the highest value in each row (in form of a vector, 1xn) and a vector full of the values themselfes (size 1xn), which would mean for the example:
2 1 2 2 2
and
24 23 6 12 18
I have to do that for a lot of iterations build into a GUI, so I want to fasten it a bit up and stop using a for loop with if cases. Same values in both entries is mathimatically impossible.
Could someone please help me with that?
PS: The programm needs to run on Matlab version since 2013

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 6 月 25 日

0 投票

v=[17 23 4 10 11; 24 5 6 12 18]
[a,idx]=max(v)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で MATLAB についてさらに検索

製品

質問済み:

2015 年 6 月 25 日

コメント済み:

2015 年 6 月 25 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by