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!