Strange Matlab error: "??? Subscript indices must either be real positive integers or logicals"

Posted by Roee Adler on Stack Overflow See other posts from Stack Overflow or by Roee Adler
Published on 2010-05-31T16:21:52Z Indexed on 2010/05/31 16:23 UTC
Read the original article Hit count: 303

Filed under:
|

I have a function func that returns a vector a. I usually plot a and then perform further analysis on it. I have a certain scenario when once I try to plot a, I get a "??? Subscript indices must either be real positive integers or logicals" error. Take a look at the following piece of code to see the vector's behavior:

K>> a

a =
    5.7047    6.3529    6.4826    5.5750    4.1488    5.8343    5.3157    5.4454    

K>> plot(a)
??? Subscript indices must either be real positive integers or logicals.

K>> for i=1:length(a); b(i) = a(i); end;
K>> b

b =
    5.7047    6.3529    6.4826    5.5750    4.1488    5.8343    5.3157    5.4454    

K>> plot(b)
??? Subscript indices must either be real positive integers or logicals.

The scenario where this happens is when I call function func from within another function (call it outer_func), and return the result directly as outer_func's result. When debugging inside outer_func, I can plot a properly, but outside the scope of outer_func, its result has the above behavior.

What can cause this? Where do I start from?

© Stack Overflow or respective owner

Related posts about matlab

Related posts about plot