Adjusting For loop size

1 visualización (últimos 30 días)
Jared
Jared el 13 de Feb. de 2013
If I am doing something like:
for i=1:length(array)
if length(array(i)) < 10
array(i)=[];
i=i-1;
end
end
When I delete that index, the array is no longer the same length as the for loop, so I am getting an index exceeds matrix dimensions error. How can I adjust the length of the for loop?

Respuesta aceptada

Jason Ross
Jason Ross el 13 de Feb. de 2013
I think you are looking for a while loop rather than a for loop.
  1 comentario
Jared
Jared el 13 de Feb. de 2013
You're right, forgot about them. It's too early...

Iniciar sesión para comentar.

Más respuestas (0)

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