Lines that would be executed even if an error occur or if the script is aborted
古いコメントを表示
When running a script and an error occurs, everything stop. The lines following the line where the error occurred wont be executed. Same think if I do ctrl-c to abort the execution.
I am using fopen and a visa object. I always have to run those line at the end of the script to close the communication to be able to reopen it when rerunning the script:
fclose(vu);
delete(vu)
clear vu
Is there a way to get these lines executed even if an error occurs before these lines or if I use ctrl-c before the script gets to these lines.Like an emergency part of the code that have always to be executed at the end no matter what.
What I am doing now is write those line manually those line in the command window when my script fails.
Thanks
採用された回答
その他の回答 (1 件)
Walter Roberson
2011 年 9 月 30 日
0 投票
No, there is no way to do what you want with a script. With newer versions of MATLAB, however, it can be done inside a function, using oncleanup().
カテゴリ
ヘルプ センター および File Exchange で Variables についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!