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

5 views (last 30 days)
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

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 25 Jun 2015
v=[17 23 4 10 11; 24 5 6 12 18]
[a,idx]=max(v)

More Answers (0)

Categories

Find more on Operating on Diagonal Matrices in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!