How to get elapsed time of a code in matlab ?

1 次查看(过去 30 天)
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 个评论
dpb
dpb 2022-8-1
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 2022-8-1
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.

请先登录,再进行评论。

回答(2 个)

John D'Errico
John D'Errico 2022-8-1
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 2022-8-1

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by