MATLAB Answers

Isti
0

How to know the location of the minimun value from a vector?

Asked by Isti
on 6 May 2012
I have a vector like this: A =
0.2008 0.2011 0.2011 0.1979 0.2003
then the minimun value is: 0.1979 which located on (1,4)
So I want to take the location of that value like above. What to do? Thanks before :')

  0 Comments

Sign in to comment.

2 Answers

Answer by Andrei Bobrov
on 6 May 2012
 Accepted Answer

A = [0.2008 0.2011 0.2011 0.1979 0.2003]
[c,idx] = min(A)
for matrix
eg:
A = rand(8);
solution:
[vc,irows] = min(A);
[v,icols] = min(vc);
out = [v irows(icols) icols];
or:
v = min(A(:));
[irows,icols] = find(A == v);
or:
[v,ii] = min(A(:));
[irows,icols] = ind2sub(size(A),ii);

  0 Comments

Sign in to comment.


Answer by zhenqiang on 6 May 2012

good learning

  0 Comments

Sign in to comment.