[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: about the minimum of elements of a matrix
From: |
Martin Helm |
Subject: |
Re: about the minimum of elements of a matrix |
Date: |
Mon, 27 Dec 2010 16:34:46 +0100 |
User-agent: |
KMail/1.13.5 (Linux/2.6.34.7-0.5-desktop; KDE/4.5.4; x86_64; ; ) |
Am Montag, 27. Dezember 2010, 10:52:56 schrieb Jaroslav Hajek:
> On Tue, Dec 21, 2010 at 11:00 AM, CdeMills <address@hidden>
wrote:
> > Martin Helm wrote:
> >> This will show the first element which has the minimum value. If all
> >> index pairs are of interest where the matrix has its minimum value:
> >>
> >> val = min(A(:));
> >> [i,j] =ind2sub(size(A),find(A==val));
> >
> > The problem with 'find' is that it may return a vector instead of a
> > scalar.
>
> So what? ind2sub can perfectly handle a vector as well.
I also do not really understand why the vector should be a problem. Btw my
ind2sub in the example is completely superflous. Doug Stewart already gave the
simpler syntax which does the same, since find is clever enough to output the
right result when called with two result parameters
[i, j] = find(A==val)
which is less noisy. I somehow did not notice that before.