Adjusting For loop size

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?

 채택된 답변

Jason Ross
Jason Ross 2013년 2월 13일

0 개 추천

I think you are looking for a while loop rather than a for loop.

댓글 수: 1

Jared
Jared 2013년 2월 13일
You're right, forgot about them. It's too early...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

질문:

2013년 2월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by