Use a double as an index for another double works once and that gives indexing error.
조회 수: 5 (최근 30일)
이전 댓글 표시
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
채택된 답변
Cris LaPierre
2020년 12월 22일
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)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!