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
MATLAB runtime
10 views (last 30 days)
Show older comments
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!
Accepted Answer
David Young
on 8 Mar 2011
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.
0 Comments
More Answers (5)
John
on 8 Mar 2011
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
0 Comments
Walter Roberson
on 8 Mar 2011
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.
0 Comments
Andreas Goser
on 9 Mar 2011
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.
0 Comments
ravindra mg
on 26 Oct 2020
i have downloaded matlab and i dont know how to use it to run matlab code
3 Comments
ravindra mg
on 26 Oct 2020
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
on 26 Oct 2020
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.
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!