condition in a loop

조회 수: 1 (최근 30일)
Busy Bee
Busy Bee 2018년 1월 29일
댓글: Busy Bee 2018년 1월 29일
I have the loop as given below. But I need to restrict the value of b till 30, i.e. the value of b cannot exceed 30. 'a' value does not have a limit. I am not sure how to proceed.
a=0;
b=0;
g=a+b;
while g<100
a=a+1
b=b+1
g=a+b
end

채택된 답변

Birdman
Birdman 2018년 1월 29일
편집: Birdman 2018년 1월 29일
a=0;
b=0;
g=a+b;
while g<100
if b<30
b=b+1
else
end
a=a+1
g=a+b
end
  댓글 수: 1
Busy Bee
Busy Bee 2018년 1월 29일
Thank you!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by