Recovering workspace after exiting Matlab

102 ビュー (過去 30 日間)
Febrio
Febrio 2011 年 12 月 14 日
コメント済み: Emir Semsic 2019 年 2 月 6 日
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

採用された回答

Walter Roberson
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 件のコメント
Febrio
Febrio 2011 年 12 月 14 日
Thanks Walter.

サインインしてコメントする。

その他の回答 (1 件)

Michael Melnychuk
Michael Melnychuk 2015 年 1 月 26 日
I think the core dev's should consider adding an autosave/recover function.
  3 件のコメント
Stephen23
Stephen23 2016 年 2 月 2 日
編集済み: Stephen23 2016 年 2 月 2 日
Just imagine the complaints:
"MATLAB auto-saved three Tebibytes of data onto my harddrive..."
"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.
Emir Semsic
Emir Semsic 2019 年 2 月 6 日
So you're saying we should use functions instead of scripts?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by