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!