force stop condition in a loop
3 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (2 件)
Dennis
2018 年 7 月 30 日
編集済み: Dennis
2018 年 7 月 30 日
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.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!