Index exceeds the number of array elements (1).

182 visualizaciones (últimos 30 días)
Ioannis Vourvachakis
Ioannis Vourvachakis el 14 de Oct. de 2021
Comentada: Ioannis Vourvachakis el 14 de Oct. de 2021
I ran a file, but an error appears in the follownig line:
Refset=sol(iii(1:first_members),:);
with the message: Index exceeds the number of array elements (1).
What does it mean? Thank you.
  2 comentarios
Mathieu NOE
Mathieu NOE el 14 de Oct. de 2021
hello
go in debug mode and test the dimension of your data
  • check size of iii vs first_members
  • check size of sol vs iii(1:first_members)
Ioannis Vourvachakis
Ioannis Vourvachakis el 14 de Oct. de 2021
thank you very much

Iniciar sesión para comentar.

Respuestas (1)

Cris LaPierre
Cris LaPierre el 14 de Oct. de 2021
The error means you are trying to index a vector/array element that does not exist in your variable. Specifically, your error message is telling you your array has a single element, and your index is >1.
% Works
A = 27;
A(1)
ans = 27
% doesn't work
A(2)
Index exceeds the number of array elements. Index must not exceed 1.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by