Azzera filtri
Azzera filtri

how to stop executing while loop?

2 visualizzazioni (ultimi 30 giorni)
Ramesh Singh
Ramesh Singh il 28 Ott 2020
Commentato: Ramesh Singh il 28 Ott 2020
x=1;
while x>0
x+1
end
  2 Commenti
KSSV
KSSV il 28 Ott 2020
This is an infinite loop...it will not stop....to force stop use ctrl + c .
Ramesh Singh
Ramesh Singh il 28 Ott 2020
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

Accedi per commentare.

Risposta accettata

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

Più risposte (1)

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

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by