Use a double as an index for another double works once and that gives indexing error.
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
NMarco
el 22 de Dic. de 2020
Comentada: NMarco
el 22 de Dic. de 2020
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 comentarios
Respuesta aceptada
Cris LaPierre
el 22 de Dic. de 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)
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!