force stop condition in a loop
显示 更早的评论
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
回答(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
2018-7-30
0 个投票
HAve a look on break.
3 个评论
liran avraham
2018-7-30
编辑:liran avraham
2018-7-30
KSSV
2018-7-30
Whats the criteria for force stop?
liran avraham
2018-7-30
类别
在 帮助中心 和 File Exchange 中查找有关 Texas Instruments C2000 Processors 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!