How to get elapsed time of a code in matlab ?

조회 수: 2 (최근 30일)
Adnan Hayat
Adnan Hayat 2022년 8월 1일
댓글: Walter Roberson 2022년 8월 1일
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에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by