iteration(it).NO=length_without_zero(CH); But i have this error in this line of my matlab code: Subscript indices must either be real positive integers or logicals.
Asked
Active
Viewed 129 times
-4
-
4That must be the most frequent question asked about Matlab on SO. Try typing the title of your question into the Stack Overflow search bar. If you don't find your answer there, please read [how to ask](http://stackoverflow.com/help/how-to-ask) and edit your question accordingly. – Hoki May 08 '15 at 14:40
1 Answers
0
In matlab, indexing is done from one. I'm guessing that iteration is a vector that you storing data in? If you type
iteration(0) = 10;
Then you will get that error message. My guess is that you come from another programming language where the value of 0 is used to refer to the first element of an array. Are you doing a loop to update the values in iteration? If so, you should do your loops with the it variable starting at 1. Like so;
for it = 1 : 10
iteration(it) = it - 1;
end

PicnicTripper
- 295
- 1
- 3