Save data before error

13 ビュー (過去 30 日間)
jamaledin
jamaledin 2012 年 11 月 14 日
コメント済み: Hung Dao 2021 年 3 月 3 日
Hi. I have run a MATLAB code and at the last step it faced with error. Running process takes me time about 7 days, so, I want to save available data until this step to the file. I could not see any data in workspace. Please let me know how can I save these data. Cheers,
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 11 月 14 日
What kind of data do you want to save

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

回答 (1 件)

Matt Fig
Matt Fig 2012 年 11 月 14 日
編集済み: Matt Fig 2012 年 11 月 14 日
I recommend you either wrap all of your code in a TRY-CATCH or use DBSTOP so that you don't lose your data again. Note that if you use the TRY-CATCH approach, you should wrap the code itself, not wrap a function call! If the reason for this is not clear, play around with the idea before you use it on code that takes hours or days to run...
try
% Your code
catch
% Save everything in the WS to mycode_errored.mat
save mycode_errored
end
or
% This will stop in debug mode if an error occurs.
% so that you can examine all data, save whatever, etc.
dbstop if error
% Run your code here.
  3 件のコメント
Adam
Adam 2019 年 10 月 7 日
編集済み: Adam 2019 年 10 月 7 日
Use the 'Pause on errors' option in the Run menu and it will stop on the line of the error, with the current workspace available to you to do whatever you like with on command line.
Hung Dao
Hung Dao 2021 年 3 月 3 日
I am experiencing the same issue. it takes me days to run the code.
I upload my code and run it on a supercomputer so I cannot use the 'Pause on errors' function.
Is there anyway to save all the data, variables, workspace at the time where an error occur?

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

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by