Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!22g2000hsm.googlegroups.com!not-for-mail
From:  ImageAnalyst <imageanalyst@mailinator.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Strange errors
Date: Wed, 31 Oct 2007 19:32:43 -0700
Organization: http://groups.google.com
Lines: 91
Message-ID: <1193884363.080919.312120@22g2000hsm.googlegroups.com>
References: <ffsuk8$331$1@fred.mathworks.com>
NNTP-Posting-Host: 75.186.67.199
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Trace: posting.google.com 1193884363 13515 127.0.0.1 (1 Nov 2007 02:32:43 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 1 Nov 2007 02:32:43 +0000 (UTC)
In-Reply-To: <ffthkg$dd$1@fred.mathworks.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: 22g2000hsm.googlegroups.com; posting-host=75.186.67.199;
Xref: news.mathworks.com comp.soft-sys.matlab:435548



On Oct 26, 4:10 pm, "Matthew Sullivan" <nos...@nospam.no> wrote:
>  ImageAnalyst <imageanal...@mailinator.com> wrote in message
>
> <1193413162.578228.104...@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?- Hide quoted text -
>
> - Show quoted text -

===========================================
Matthew:
Are you 100% sure that negative is NEVER null?  Does it still crash if
you do something like:
negative = find(ydata < 0);
if ~isempty(negative)
    plot(xdata(negative), -ydata(negative), '.');
end
Regards,
ImageAnalyst