How can I exclude some code from being published to document?

6 ビュー (過去 30 日間)
QiQin Zhan
QiQin Zhan 2013 年 3 月 1 日
コメント済み: Steven Lord 2022 年 10 月 21 日
How can I exclude some code from being published to document?

回答 (1 件)

Thomas Busch
Thomas Busch 2022 年 10 月 21 日
I have this question, too. My example has a lot of extra plotting and annotation to explain the code snippet, but it really adds nothing to the basic example. I'd like to exclude everything except the lines that actually exercise the function.
  1 件のコメント
Steven Lord
Steven Lord 2022 年 10 月 21 日
One relatively easy way to do this would be to extract those "extra plotting and annotation" lines of code into a separate function (perhaps one that you include at the end of the file as kind of an appendix) that you can call from the document to be published. The published code would include the call to the function in the location from which it is called, but if you give it a name that clearly indicates that it's a helper readers of the published document may simply accept it and move on to read the more relevant explanation of the functionality you're demonstrating.
If you're doing the same type of plotting and annotating in multiple documents, this also facilitates code reuse.

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by