How to get elapsed time of a code in matlab ?

1 visualización (últimos 30 días)
Adnan Hayat
Adnan Hayat el 1 de Ag. de 2022
Comentada: Walter Roberson el 1 de Ag. de 2022
Hello,
I run a code of two variables which does not contain any function. I simply run a partial differential equation using forward difference farmula inside two loops of time and space. I use 'tic' and 'toc' to get the elapsed time of the code at the end. But I need this time in advance as my code takes hours to give result. Can I get the expected elapsed time in advance ?
  4 comentarios
dpb
dpb el 1 de Ag. de 2022
Just turn off any power-off settings and, of course, be sure the machine is on an UPS so it doesn't lose power.
Then add code to the end of the process that notifies you by <SendTextMessageFromMatlab> when it's done.
As far as predicting how long that will be other than extremely crudely, that's <Merlin>'s arena...
Walter Roberson
Walter Roberson el 1 de Ag. de 2022
How long is it going to take to clean your garage? You are not permitted to use your records of how long it has taken you in the past to clean garages of similar size, and you are not permitted to clean a fraction of the garage and use the timing to estimate the total time.

Iniciar sesión para comentar.

Respuestas (2)

John D'Errico
John D'Errico el 1 de Ag. de 2022
Sorry, but no.
A prediction of the time required for some arbitrary piece of code will never happen. It cannot happen. Well, not true. If you run the code in advance, EXACTLY as you will call it, then the predicted time is just the time it took the last time you ran that same problem.
You can run smaller problems, then figure out how the problem size will extrapolate up, but even that is rarely something you can predict at all well.

Walter Roberson
Walter Roberson el 1 de Ag. de 2022

Categorías

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

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by