Working around "Index exceeds matrix dimensions"
Show older comments
I am looking for peaks in a trace with the following code.
for i= 1:length(y)
if y(i) < -0.02 && y(i-1) > -0.02
c=c+1;
n(c,:)=abs(y(i:i+npts-1));
end
end
sometimes i get the error "Index exceeds matrix dimensions" if a peak happens at the end of the trace and there aren't enough points to populate the row in "n"
I would like to either ignore this peak or fill the the missing positions with zeros. Any suggestions on how?
Thanks
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!