force stop condition in a loop
Mostrar comentarios más antiguos
can i add a condition in a loop that identify force stop (ctr+c) ? for example i control with matlab in a current source in a infinite loop (while(1)), and i want it to turn off when i stoped the loop with ctr+c for example: if force stop fprintf(device, ':OUTP OFF'); end
Respuestas (2)
mytest()
function mytest()
finishup = onCleanup(@() mycleanup());
myloop();
end
function myloop()
while true
disp('running')
pause(1)
end
end
function mycleanup()
disp('stopped')
end
However maybe a loop that runs until a specific button is pressed is a cleaner approach.
KSSV
el 30 de Jul. de 2018
0 votos
HAve a look on break.
3 comentarios
liran avraham
el 30 de Jul. de 2018
Editada: liran avraham
el 30 de Jul. de 2018
KSSV
el 30 de Jul. de 2018
Whats the criteria for force stop?
liran avraham
el 30 de Jul. de 2018
Categorías
Más información sobre Texas Instruments C2000 Processors en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!