Path: news.mathworks.com!not-for-mail
From: "Matthew Sullivan" <nospam@nospam.no>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Strange errors
Date: Fri, 26 Oct 2007 20:10:56 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 72
Message-ID: <ffthkg$dd$1@fred.mathworks.com>
References: <ffsuk8$331$1@fred.mathworks.com> <1193413162.578228.104670@o3g2000hsb.googlegroups.com>
Reply-To: "Matthew Sullivan" <nospam@nospam.no>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1193429456 429 172.30.248.38 (26 Oct 2007 20:10:56 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 26 Oct 2007 20:10:56 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1142155
Xref: news.mathworks.com comp.soft-sys.matlab:434820



 ImageAnalyst <imageanalyst@mailinator.com> wrote in message
<1193413162.578228.104670@o3g2000hsb.googlegroups.com>...
> On Oct 26, 10:46 am, "Matthew Sullivan" <nos...@nospam.no>
wrote:
> > I've been running in to a strange MATLAB script problem that
> > I don't quite understand.  The specific error I get is
> > "Subscript indices must either be real positive integers or
> > logicals."  The indices I use are real positive integers,
> > though. When I copy and past the offending commend in to the
> > MATLAB command line, it executes without issue.
> >
> > The most frustrating thing is that the errors are not
> > repeatable.  If I clear memory and rerun, it sometimes will
> > work.  Other times, it seems to stop elsewhere in the
> > script, or at another point in the loop.  I've only recently
> > run in to this issue, as well.  I can sometimes get the
> > error running older code that I hadn't run in a long time
> > and had no problems with when I ran it months ago.
> >
> > I assume there's something wrong with my computer or the
> > script I'm running.  As it appears somewhat randomly I am at
> > a loss for fixing it.  For completeness, here is my most
> > recent error message:
> >
> > ?? Subscript indices must either be real positive integers
> > or logicals.
> >
> > Error in ==> track at 502
> >                 ym = y(ymat(1:lenxn,1:lenxm));
> >
> > Error in ==> deflect_stitch_2 at 103
> >             trt = track(xyt', trackdist, params);
> >
> > lenxn = trackdist = 25
> 
> ============================================================
> Put a breakpoint there and check the workspace to see if
it calls ymat
> an array of integers or doubles.
> Also, you can do class(ymat) in the command window at that
breakpoint
> to see what MATLAB thinks it really is.
> It will report back the data type it considers it: some
flavor or
> floating point, or some flavor of integer.
> Good luck,
> ImageAnalyst
> 


Thanks for the suggestions, but I'm afraid I didn't do a
good job of detailing my problem.  I am running data
analysis on a number of files in a loop.  The command that
crashes is always a pair like this:

negative = find(ydata < 0);
plot(xdata(negative), -ydata(negative), '.');

for most of the iterations through the loop, it works fine,
but at some point it gives the above message.  The confusing
things to me are:

1)  it doesn't always stop at the same place in the loop
2)  it doesn't always happen, sometimes it works, sometimes
it doesn't
3)  if I look at the array negative, it is filled with
positive integers.  max(negative-floor(negative)) = 0.
4)  if I simply copy the failed command from the command
window the command works without fail.

My real question is:  why does the same exact code not
always produce the same exact results?