index exceeds no of array elements

1 visualización (últimos 30 días)
Shalu Mathew
Shalu Mathew el 23 de Feb. de 2020
Respondida: Image Analyst el 23 de Feb. de 2020
I ran a matlab code today and I recieved this error. Hope you guys can help.
BB= 4000;
UB = rand((t-q),BB);
indx = round(1+(t-q+1)*UB);
estar = ehat(indx);
Index exceeds the number of array elements (237).

Respuestas (1)

Image Analyst
Image Analyst el 23 de Feb. de 2020
What about the error do you not understand? It says that the "Index exceeds the number of array elements" meaning that indx is greater than the length of ehat array which is 237. That is unless you overwrote the built-in functions rand() and round() with your own functions or variables. Take the semicolon off and see what it is:
indx = round(1+(t-q+1)*UB)
whos indx
whos ehat
estar = ehat(indx);

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!

Translated by