Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Subscript indices must either be real positive integers or logicals Error + Code
Replies: 2   Last Post: Feb 21, 2013 9:42 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
dpb

Posts: 8,115
Registered: 6/7/07
Re: Subscript indices must either be real positive integers or logicals
Error + Code

Posted: Feb 20, 2013 5:56 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 2/20/2013 11:24 AM, Jerome wrote:
> was wondering if someone can explain to me what this error means. And,
> if possible, how to resolve it? ??? Subscript indices must either be
> real positive integers or logicals.


Pretty much exactly what it says--Matlab arrays are 1-based so all
indices have to start at (at least) one ("real positive integers" part)
or be logical indices which are an array of T,F that select the subset
within the array on that logic basis rather than by absolute position.

> Error in ==> interp2>linear at 344
> F = ( arg3(ndx).*(onemt) + arg3(ndx+1).*t ).*(1-s) + ...
>
> Error in ==> interp2 at 220
> zi = linear(ExtrapVal,x,y,z,xi,yi);
>
> Error in ==> snake at 71
> ssx = gamma*xs - kappa*interp2(fx,xs,ys);
>
> This is my complete code:
>

...

> eext = (double(wl.*eline) + double(we.*eedge -wt) .* eterm); %eext as a
> weighted sum of eline, eedge and eterm
>
> [fx, fy] = gradient(eext); %computing the gradient

...

Somehow you've passed an illegal set of inputs to interp2() that has
caused it to error. You can tell this by tracing back the errors to the
initiating call. I don't have time at present to try to delve deeply
into your code but the three-argument form of the call to interp2
assumes the V (fx) here is a set of function values that match 1:M and
1:N for the size of the array in the two dimension. I'm suspecting this
probably isn't so is the root cause that confused interp2.

Study

doc interp2

and the examples carefully to see where it went wrong.

--




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.