Plot error of results from a function "Subscript indices must either be real positive integers or logicals."

1 view (last 30 days)
I have build up a quite large main file, which uses a function to read some test data (and functions inside reading function to do some data processing).
When I in the main file try to plot the results i get from my reading function, Matlab returns the error message "Subscript indices must either be real positive integers or logicals."
I tried to debug it, by running through the reading function. The step before I return to the main file i make a plot of the data readed without any problems. When i take the next step and do a plot on the same data i get the error message.
I have also tried with renaming the output from the function to the same as in the function file, and used other names, but it didn't help.
Anyone there have an idea of why i can't plot the results in the main file?

Accepted Answer

Star Strider
Star Strider on 24 May 2014
Without seeing your code it’s difficult to say.
First, check to see the data your reading function returns to your main script. If it plots inside the reading function but not with data returned from it, either the reading function is not returning the correct data, or the calling program isn’t allocating the returned output the way you believe it is.
You could also be calling an anonymous or other function that is not actually in your workspace. MATLAB interprets the negative, zero, or non-integer argument to the function as an index. Another possibility is that the function name is misspelled, or you may have used the name of the function as an array name somewhere in your code. Of course you could be passing a negative, zero, or non-integer subscript to an array your reading function returns.
Guessing here, but these are the most likely possibilities.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!