how to remain in the loop until the user gives the specific command?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
SYED GILLANI
el 17 de Oct. de 2016
Editada: Walter Roberson
el 17 de Oct. de 2016
I want to run a loop with having some instruction after those instruction it should ask weather to remain in the loop or exit the loop. how can i implement this ?
0 comentarios
Respuesta aceptada
Walter Roberson
el 17 de Oct. de 2016
Editada: Walter Roberson
el 17 de Oct. de 2016
while true
fprintf('Watch the chicken cross the road!\n');
YN = input('Do you know why yet? Y or N', 's');
if strcmpi(YN, 'y')
break;
end
for K = 1 : randi(3)
fprintf('Cluck! ');
end
fprintf('\n');
end
fprintf('Bawk!\n');
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!