Recovering workspace after exiting Matlab
72 次查看(过去 30 天)
显示 更早的评论
Hi guys,
I have made a big mistake by not including a command to save my workspace after my simulation ends. My computer shut down and now I don't have most of the matrices from my simulation results. Is it possible at all to recover my workspace after I exited Matlab without saving them? I've googled this and everybody says it's impossible. Just in case anybody has a different answer.
cheers,
Febrio
0 个评论
采纳的回答
Walter Roberson
2011-12-14
The data is gone. MATLAB keeps workspace contents in memory and does not bother to write the contents to disc unless it is asked to.
更多回答(1 个)
Michael Melnychuk
2015-1-26
I think the core dev's should consider adding an autosave/recover function.
3 个评论
Stephen23
2016-2-2
编辑:Stephen23
2016-2-2
Just imagine the complaints:
"I relied on MATLAB to auto-save my data, but I don't have enough diskspace and it missed some of my data. How do I get this missing data?"
"MATLAB is sooooo sloooow... " (while MATLAB tries in the background to save fifty Gibibytes of data).
"I reverted my workspace to the saved version... but now I changed my mind. How do I get my first workspace back?"
The only complete solution would be to back up every code step and every variable at every change. This works great if you have infinite disk-space and infinite computing power.
A more robust solution is to:
- Stop writing scripts and learn to write functions.
- Stop relying on the base workspace. This workspace is for playing around, not for serious work. Use functions!!!
- Keep track of data and save it when possible. This is easy with functions, as processing can be re-started from the last saved data.
- Avoid amateur commands like clear all. Have a good look at well-written code on MATLAB File Exchange: none of them use clear all. In fact most of them are functions, not scripts. The reason: to encapsulate their functionality and workspace (in other words: to manage their data properly, so that it is not in the base workspace, so that other people cannot mess it up).
- Oh, and learn to use functions instead of scripts.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!