Borrar filtros
Borrar filtros

"index out of bounds" error

1 visualización (últimos 30 días)
siddhesh rane
siddhesh rane el 23 de Mayo de 2013
Respondida: Tasneem el 13 de Jul. de 2022
Why am I getting Index out of bound error with below mentioned code?
S = size(coordinates,1);
n = 0;
while(n<S)
o = 1;
while(o<10)
D = rand(3,1);
n = n+1;
X(n)= coordinates(n);
n = n+1;
Y(n)= coordinates(n);
n = n+1;
Z(n)= coordinates(n);
end
patch(X,Y,Z,D);
hold on;
end

Respuestas (1)

Tasneem
Tasneem el 13 de Jul. de 2022
It is my understanding that your code has two while loops. The inner while loop seems to be an infinite loop since you are not incrementing o anywhere in the code and you are also incrementing the value of n in the inner while loop which eventually exceeds the index range of coordinates and gives you the 'index out of bound' error.

Categorías

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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by