how to stop executing while loop?

조회 수: 3 (최근 30일)
Ramesh Singh
Ramesh Singh 2020년 10월 28일
댓글: Ramesh Singh 2020년 10월 28일
x=1;
while x>0
x+1
end
  댓글 수: 2
KSSV
KSSV 2020년 10월 28일
This is an infinite loop...it will not stop....to force stop use ctrl + c .
Ramesh Singh
Ramesh Singh 2020년 10월 28일
i already type this statement and it run , then i type clc clear delete variable it does't work,
thank kssv ctrl+c is right to stop

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

채택된 답변

KSSV
KSSV 2020년 10월 28일
You can set a condition like below and exit the while loop.
x=1;
while x<10
x = x+1 ;
end

추가 답변 (1개)

Alan Stevens
Alan Stevens 2020년 10월 28일
Use a condition inside the while loop, such as
if x>10, break, end

카테고리

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

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by