"clear all" causing annoying warning messages
古いコメントを表示
I am using "clear all" at the start of a ".m" file that I have written myself (lets call it "myfile.m"). When I run the file, I get three identical messages stating "Warning: The file 'myfile.m' could not be cleared because it contains MATLAB code that is currently executing." I don't want to turn warnings off, because I am writing my own warnings later in the file. Why does this happen and how can I prevent it? I am using Matlab version 2017a.
2 件のコメント
KSSV
2017 年 8 月 8 日
Are you sure Clear all is placed only at the start of the code?
"clear all" causing annoying warning messages"
Putting clear all at the top of every script is one of the most common signs of cargo-cult programming in MATLAB. The best solution is: do not put clear all at the top of every mfile, and learn to write functions. Problem solved!
Search this forum to know more about why putting clear all everywhere is a bad practice (as you are starting to find out):
etc, etc, etc.
採用された回答
その他の回答 (1 件)
David Cazenave
2024 年 4 月 9 日
移動済み: Stephen23
2024 年 4 月 10 日
0 投票
You can still turn off the warnings, and then turn them back on before your 'custom warnings.' If that helps, Thank you ... Thank you very much.
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!