When I execute my script, one of the lines of code sets a variable to a 2x2 array of zeros. If I set a breakpoint, highlight the line and execute it in the command window, it produces an integer (which it should).
The other line sets first_peak to 0, when it should be 667.
(I added the cast in an attempt to resolve the problem because matlab was complaining about the variable type. Of course it didn't work.)
I can't seem to create an MWE without one of my datafiles, so attached are screenshots.
in-script:
command window:
If an MWE were going to produce the error, this one should, but again, it doesn't. The peaks(peak_ndx+1) line would produce the aforementioned 2x2 array, and peaks(peak_ndx) would produce the 0 value.
clear
for ndx = 1 : 6
peaks = [667 911 1288 1719 2114 2363 3505 3718 4010 4372 4682 4867];
peak_ndx=(ndx - 1) * 2 + 1;
peaks(peak_ndx)
peaks(peak_ndx+1)
end



peaksis a function. It is wise to change your array name.doc peaksjust said it is a variable. Will have a look.peaksfunction. Tryclear peaks; doc peaks