Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Finding minimums
Date: Thu, 5 Aug 2010 17:21:06 +0000 (UTC)
Organization: Pathfinder Energy Services Ltd
Lines: 40
Message-ID: <i3eru2$sf5$1@fred.mathworks.com>
References: <i3eoh8$jgc$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1281028866 29157 172.30.248.35 (5 Aug 2010 17:21:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 5 Aug 2010 17:21:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2159440
Xref: news.mathworks.com comp.soft-sys.matlab:659459

Matt,
You may have several elements that are equal to minnum.  You have to decide which one you want.

Example:
A = [0,1,0,0];
B = find(A == min(A(:)));

 disp(B)
     1     3     4


"Matt " <matthew.t.sherman@jhuapl.org> wrote in message <i3eoh8$jgc$1@fred.mathworks.com>...
> Hello, 
> 
> I have a problem with finding minimums and I'm not quite sure why...
> Recently I have been using the code 
> "[I,J]= find(summat == max(summat(:)))"
> 
> to find my maximums in a matrix, however, now I wish to find the minimums in my matrix and when I just substitute min in for max, I get an [8million+ x 1] for I and J.
> 
> I've tried several other ways, but none have yielded results for me yet.
> 
> Some code along the lines ...
> 
> "minnum = 1e9;
> for i = 1:2160;
>     for j = 1:4320;
>         if summat(i,j) <= minnum;
>             minnum = summat(i,j);
>             imin = i;
>             jmin = j;
>         end
>     end
> end"
> 
> was suggested to me, but I'm not quite sure how to make it stop and hold imin and jmin at the minimum value in summat.
> 
> Any help would be great,
> Thanks
> Matt