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 日

0 投票

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 日

0 投票

Use a condition inside the while loop, such as
if x>10, break, end

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

リリース

R2019b

タグ

質問済み:

2020 年 10 月 28 日

コメント済み:

2020 年 10 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by