My colleague and I were trying to iterate through an array using time steps. However, on certain time steps and time lengths, we recieve an "Array indexes must be positive indexes or logical values" error.
Why does this error appear at all?
Why does this error only appear sometimes?
We know that rounding the index prevents the error, but the index is already displayed as an integer, so why would that matter? Is it because the index (1e5) is really a decimal? (i.e. Is there a hidden decimal place not being shown to the user that makes the index not an integer?)
Any help is appreciated
Relevant Forum Posts
disp("Notice how these parameters have no error");stepThroughTime(.0001,3);disp("While these parameters do");stepThroughTime(.00001,3);function stepThroughTime(steps,time)%This function steps through an array of times%bugs: certain steps and times result in errortimes=0:steps:time;windowsize=1/steps;disp(windowsize);for b=windowsize+1:windowsize:length(times)x=b-windowsize;%When x is rounded, there is no error%x=round(x);times(x);endend