How to restart a function if it takes too long to run?

조회 수: 2 (최근 30일)
Diogo Carvalho
Diogo Carvalho 2020년 10월 24일
답변: Walter Roberson 2020년 10월 25일
Hello! I created a time stepping function to solve differential dynamic equations. Within this function I have a while loop that aims to refine the solution for each time step.
I've noticed that for very small timesteps, the function stops progressing and gets stuck. I'd like to make it so that if this happens, then the function gets reset with a new (larger) timestep. All of this would occur automatically and I was thinking about it being based on runtime.
Thank you!

답변 (1개)

Walter Roberson
Walter Roberson 2020년 10월 25일
See tic and toc, and see clock and etime
You will need to put these checks inside the code that is to be limited. There is no easy way to limit the time for a function without its active cooperation.

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by