- Stop writing cargo-cult code clear and clc at the start of your scripts.
- Learn to write functions instead of scripts.
- Read this: http://www.mathworks.com/matlabcentral/answers/228557-experts-of-matlab-how-did-you-learn-any-advice-for-beginner-intermediate-users
Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Beginnning of file considered as code section
2 ビュー (過去 30 日間)
古いコメントを表示
In my Matlab preferences I only have Sections enabled under Code Folding, so that I can fold cells (code sections). Even so, the beginning of every .m file in the Editor is flagged as the start of a code section, which lasts until the start of the next actual cell:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/164982/image.jpeg)
How can I change this behaviour? Many thanks!
2 件のコメント
Stephen23
2016 年 5 月 24 日
編集済み: Stephen23
2016 年 5 月 24 日
Noticing that there is a problem is the first step to becoming a better programmer. Here are two things you should do:
回答 (1 件)
Philip Borghesani
2016 年 5 月 24 日
編集済み: Philip Borghesani
2016 年 5 月 24 日
My first thought is don't put that code at the top of each script. Especially clear all it slows down the execution of the code because all code must be recompiled after clearing. If you must, use clear without the all to clear variables from the base workspace.
My second thought is to write functions instead of scripts or to give up and create a section marker at the top of the file:
Blast the base workspace to remove all previous work without prompting to save
clc
clear
0 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!