Dominik Foe
Dominik Foe

Reputation: 23

How to get MATLAB to display the row index of the minimum value in every column of a matrix?

I have am matrix like this:

S =

2.2100   16.0100
0.0100    9.8100
9.4100    0.0100

Now I want to know the row number of the minimum value in every column. The vector I'm looking for should look like that:

D =

 2
 3

Thank you for your help.

Upvotes: 2

Views: 3553

Answers (1)

ThiS
ThiS

Reputation: 977

[val, ind] = min (S)

and you will have the value:

val =

   0.010000   0.010000

ind =

   2   3

Upvotes: 6

Related Questions