Hi. I have wrote a code which contain main part like below.
Clc
Close all
.
.
.
While ...
.
.
.
End
I wanna force this loop to end in 7 iteration. I do this.
Clc
Close all
A=0
While A<8
While ...
.A=A+1
.
.
End
End
But it does not works. Can any body help?

 채택된 답변

Voss
Voss 2021년 12월 4일

0 개 추천

So you have some code like this, right?
A = 0;
while A < 8
% do something
A = A+1;
end
This loop will iterate 8 times (for values of A going from 0 to 7, inclusive). Is this what you observe? If not, what do you observe?

댓글 수: 3

armin m
armin m 2021년 12월 4일
편집: armin m 2021년 12월 4일
No. I wrote it wrong. It should be A<7. I mean first loop continouse while the condition (which did not mention here) have been reached. But not for more than 7 iteration! Imean this in explanation mode: do this until .... but not more than 7 loops.!
OK. How about this then?
% condition = <some unspecified condition>
A = 0;
while condition && A < 7
% do something
A = A+1;
end
armin m
armin m 2021년 12월 4일
편집: armin m 2021년 12월 4일
Did it. thankssss

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2021년 12월 4일

편집:

2021년 12월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by