필터 지우기
필터 지우기

How to stop loop without stopping the script?

조회 수: 5 (최근 30일)
Philip Nahmias
Philip Nahmias 2018년 7월 21일
편집: Matt J 2018년 7월 22일
My script samples data from multiple instruments. At the moment I use a for loop to sample the data but I need to preset its duration. What I want though is to be able to stop the sampling the moment I need to. How can I achieve that?

답변 (1개)

Matt J
Matt J 2018년 7월 21일
Use the BREAK command exit the loop early.
  댓글 수: 2
Stephen23
Stephen23 2018년 7월 22일
Philip Nahmias's "Answer" moved here:
Hey Matt thanks for your answer but that would have to be included in the code its self. I need some way to come out of the loop while the code is running, though changing some variable in the command window. but while the script is running I cant change any variable value through the command window. Is there a way I could change that?
Matt J
Matt J 2018년 7월 22일
편집: Matt J 2018년 7월 22일
There is no way to do it without changing your code.
The closest thing to what you are asking would be to put your code in an App callback. The MATLAB command window is not blocked by the running of a GUI. You can add a stop button in the GUI or have it poll the base workspace for the value of some flag variable.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by