Prevent function from printing to command window?

27 ビュー (過去 30 日間)
Blenndrman
Blenndrman 2019 年 9 月 18 日
コメント済み: Walter Roberson 2019 年 10 月 3 日
Right now, I'm running simulations and fitting routines that repeatedly call a series of functions that I've downloaded but are not open-source (i.e. I can't edit or see how they work, although they are free to use, written specifically for Matlab, and available for anyone). Each of these functions prints comments to the command window almost every time it runs, which, I'm fairly certain, is slowing my simulations considerably. Is there some way of preventing a Matlab script or function from printing to the command window at all, and is this faster?
Briefly, I'll note that using a semicolon to suppress is not what I'm talking about – that's not the solution (FWIW I'm already doing this).
  2 件のコメント
Geoff Hayes
Geoff Hayes 2019 年 9 月 18 日
Brendan - do any of these functions allow an input to suppress the output? Can you provide a link to the code that you are using?
Blenndrman
Blenndrman 2019 年 9 月 18 日
Unfortunately, there is no input to suppress these warnings. My code is a series of nested functions – it's not worth your time to go through haha. FWIW I'm using several functions built by "Easyspin" – here is the documentation on a cw EPR function called "pepper" http://easyspin.org/easyspin/documentation/pepper.html. If, for example, Exp.Range is set to be Exp.Range = [0 1000] but pepper thinks there might be a transition above 1000 mT, the Command Window will read "** Spectrum exceeds sweep range. Artifacts at upper limit possible."
When I run the code, it might print that exact statement ~150,000 times. So my question is, is there some sort of Matlab function or master command that prevents anything at all from appearing in the Command Window? If it exists, this command would be independent of the code I wrote.
I guess I was wondering if there is some master command in Matlab that overrides all methods of printing from a script to the Command Window, and prevents anything from appearing. If not, no worries!

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

採用された回答

Daniel M
Daniel M 2019 年 10 月 3 日
編集済み: Daniel M 2019 年 10 月 3 日
  1 件のコメント
Walter Roberson
Walter Roberson 2019 年 10 月 3 日
Yes, this should work. evalc() captures output that would normally go to the command window.
Note that it will capture everything, so if there are some parts you want to see as they happen, then you would need something more sophisticated.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by