how do I freeze and save entire function state?

2 views (last 30 days)
Hi, I am running a large simulation (function with "children" functions), which takes a long time to produce data. when I need to debug an event which happens after a long time, I am running the simulation with same seed and under debug mode (breakpoints), and wait. my question - is there a way of saving the whole function data and memory to a file, so I can reproduce the situation again by just loading it somehow, instead of re-running the whole simulation?
thanks.

Answers (2)

Walter Roberson
Walter Roberson on 12 Sep 2013
There is no provided mechanism to freeze and save function state.
It gets messy when you start involving objects (graphics or OOP), or open files, or threads, or additional processes (e.g, sound playing).
There is some back-tracking that can be done... but it only works on some kinds of functions if I recall.
Restoring the state would be tricky, especially as MATLAB has no way to restore a call stack.

Jan
Jan on 12 Sep 2013
You can freeze a virtual machine. So install Matlab in a new virtual machine, freeze the complete state, create a copy of the state and start it as often as your want.

Categories

Find more on Simulation 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!