필터 지우기
필터 지우기

MATLAB runtime

조회 수: 5 (최근 30일)
Hugo
Hugo 2011년 3월 8일
댓글: Walter Roberson 2020년 10월 26일
I am running a matlab function that requires processing a huge number of data that can take hours or even days. Is there a way for us to check the progress of our matlab function, i.e. the approximate time it will require MATLAB to finish computing the function?
Thanks!
  댓글 수: 1
Hugo
Hugo 2011년 3월 8일
Also, is there any way to save our progress in matlab while the function is still running, and turn off the computer? or do we absolutely have to turn it on in such cases

댓글을 달려면 로그인하십시오.

채택된 답변

David Young
David Young 2011년 3월 8일
You would have to change the program itself to display its own progress. You can do this very simply with DISP, or you could use the progress bar shown by WAITBAR. Your function should be able to work out roughly how far through it is by counting iterations of its main loop.
It makes sense to save the state of your computation periodically, using the SAVE function. Call this every N iterations of the main loop, where you choose N to make a reasonable interval. You should probably save to a sequence of files, or at least to two files alternately, to protect against the computer going down during a save. You need to ensure that SAVE has access to all the variables that you need to save in order to restart the computation. Then, if you need to restart the computation, you can use LOAD to restore the latest state that was saved.

추가 답변 (5개)

John
John 2011년 3월 8일
i would look at the help for 'waitbar' if you want some kind of indication of where the program is. in addition if you are using loops you could just print out the loop index to see where the program is (or any other comment that you want).
pausing the program could be a little tricky. you could just use the 'pause' function to halt execution at some point and wait for the user to continue. you could then save off all variables in the workspace and close matlab. the next time you run the program load in all of those variables and continue execution from where you left off

Walter Roberson
Walter Roberson 2011년 3월 8일
If you have a graphics display, and if you can edit the code, then you can add waitbar() . The standard waitbar() does not provide any time estimates, but perhaps one of the ones in the Matlab File Exchange (FEX) does.
If you do not have a graphics display but can edit the code, you can use tic() and toc() to time loops and then multiply by the number of loops remaining to estimate the time requirement.
If you have a program already running and you did not put in any code to help you determine the time or progress, then there is no mechanism to examine the progress.
There is no Mathworks supplied mechanism to save the state of a program that is running and allow it to be resumed later. If you need something like that, then your program will need to write "checkpoint" information out from time to time, and then upon resumption will need to read in the last checkpoint and carry on from there.
One thing that might help you is to use calls to the fairly new oncleanup() facility. oncleanup() is invoked even if you control-C a program, I believe. The routine you designate in oncleanup() could save the state of important variables before allowing the variables to be cleared.

Andreas Goser
Andreas Goser 2011년 3월 9일
And I can't hold back my suggestion to users with code that runs days to see whether parallel and distributed computing with MATLAB can speed up computations.

Hugo
Hugo 2011년 3월 8일
Thanks guys you are all very helpful

ravindra mg
ravindra mg 2020년 10월 26일
i have downloaded matlab and i dont know how to use it to run matlab code
  댓글 수: 3
ravindra mg
ravindra mg 2020년 10월 26일
cannot launch matlab, that's the problem. how do i launch it? i have downloaded the runtime files and ran setup. the files are in a folder but with no clue as how to launch the code builder. any helpwould be appreciated
Walter Roberson
Walter Roberson 2020년 10월 26일
The MATLAB runtime can only be used to run pre-compiled MATLAB code. The runtime does not need to be started by itself: it will be started automatically by the pre-compiled code.
To run MATLAB .m or .mlx source code or Simulink models, you need MATLAB itself, not just the runtime.
There has never been a free version of MATLAB.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by