Use a double as an index for another double works once and that gives indexing error.
5 views (last 30 days)
Show older comments
Dear experts,
I'm facing a problem and I cannot really understand what's going wrong. I'll try to make it as simple as possible.
I have 2 doubles:
- ampl = 1x1760;
- coords = 1x635;
I just need to filter (is that the right word?) values from the ampl double using the coords double. To achieve that, I perform:
ampl_filtered = ampl(coords);
That works fine as I need.
Then I have other 2 doubles:
- amplROI = 1x201;
- coordsROI = 1x41;
I run a similar line of code
amplROI_filtered = amplROI(coordsROI);
but this time I get this error:
Index exceeds the number of array elements (201).
I don't understand what's wrong here since the doubles are similar.
Both coords and coordsROI store integers, while ampl and amplROI store float numbers.
Why I get this error? What am I doing wrong?
Tank you all!
0 Comments
Accepted Answer
Cris LaPierre
on 22 Dec 2020
Look at what the error message is saying. It has nothing to do with doubles vs floats. The problem is coordsROI contains value(s) that are greater than the indices available for amplROI (only 201 elements).
Here's a simple recreation of the error.
A = [1 2];
A(5)
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!