Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
Diogo Carvalho
Diogo Carvalho el 24 de Oct. de 2020
Respondida: Walter Roberson el 25 de Oct. de 2020
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!

Respuestas (1)

Walter Roberson
Walter Roberson el 25 de Oct. de 2020
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.

Categorías

Más información sobre Get Started with Optimization Toolbox en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by