index exceeds no of array elements

3 次查看(过去 30 天)
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).

回答(1 个)

Image Analyst
Image Analyst 2020-2-23
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);

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by