필터 지우기
필터 지우기

how can I break a while loop if it stuck at one function in this loop?

조회 수: 1 (최근 30일)
Jingying Wang
Jingying Wang 2017년 11월 14일
답변: Walter Roberson 2017년 11월 14일
Hi everyone! I'm running a while loop. It stucks sometimes on startSimulation function inside this while loop. It's not a error, but it runs for forever! I just want to break the while loop if this takes too long time like more then 1 minute.
while 1
Charge = startSimulation(t0,tf,initialState,I1C,param);
if SOC>80
break
end
end

답변 (1개)

Walter Roberson
Walter Roberson 2017년 11월 14일
If you need to be able to limit the amount of time taken by an operation, then you need the Parallel Computing toolbox. You need to run the operation using parfeval(). You can then use wait() with a timeout; if the timeout expires then you can cancel() the future

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by