Path: news.mathworks.com!not-for-mail
From: "Walter Roberson" <roberson@ibd.nrc-cnrc.gc.ca>
Newsgroups: comp.soft-sys.matlab
Subject: Re: isfinite to find max w/o including Inf
Date: Tue, 28 Oct 2008 21:33:01 +0000 (UTC)
Organization: National Research Council of Canada
Lines: 27
Message-ID: <ge80ed$7l9$1@fred.mathworks.com>
References: <ge7ita$jdd$1@fred.mathworks.com>
Reply-To: "Walter Roberson" <roberson@ibd.nrc-cnrc.gc.ca>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1225229581 7849 172.30.248.37 (28 Oct 2008 21:33:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 28 Oct 2008 21:33:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 434782
Xref: news.mathworks.com comp.soft-sys.matlab:497709


"Diego Zegarra" <diegozbb@gmail.com> wrote in message <ge7ita$jdd$1@fred.mathworks.com>...
> Could someone please tell me whats wrong with my code?

> h = MTT{m}(MSchJ{m}(end),:);
> MAXP = [MAXP; max(h(isfinite(MTT{m}(MSchJ{m}(end),:)),1))];

That is equivalent to

MAXP = [MAXP; max(h(isfinite(h),1))];

Did you perhaps mean

MAXP = [MAXP; max(h(isfinite(h)),1)];

that is, taking the maximum along the first dimension
rather than access the first column of h?

We can see from the definition of h that is expected
to be exactly one entire row, so it is going to be 1 x something.
isfinite(h) would be the same size, 1 x something.
You then use that 1 x something logical array as the -first-
index of h rather than as the -second- index of h,  as if you
were attempting to access a something x 1 array. And since it
doesn't have all those rows and you explicitly specified the
second dimension it knows that you aren't just using logical
indexing relative to the beginning of the array... so it bombs out.