Re: semi-colon suppress output of user defined function
- From: "Steven_Lord" <slord@xxxxxxxxxxxxx>
- Date: Fri, 13 May 2011 11:51:00 -0400
"Andy " <myfakeemailaddress@xxxxxxxxx> wrote in message news:iqjg3l$570$1@xxxxxxxxxxxxxxxxxxxxxxxxxxx
The problem you're having is that the semicolon suppresses OUTPUT (that is, will not display the RETURNED values). 'Output' does not refer to all data printed to the command line during execution.
It sounds like you're implementing a 'verbose' option to your function, and this should be done via an optional argument, not the semicolon supression.
for ix = 1:1e5
printf('Currently executing loop %d', ix);
% do whatever in the loop
As a matter of good program design, your functions probably should never print directly to the screen. If you want them to, the caller should pass the 'verbose' option, and every print statement should be wrapped in:
Or even better, you shouldn't just DISP/FPRINTF/etc. you should call a logging function:
for ix = 1:1e5
and let the logging function determine what information to write and to where it should be written (screen if verbose is 'display', a log file if verbose is 'logging', etc.) To add a new log destination or logging "level" in the future all you need to do is modify the one logDiagnostics function rather than dozens or hundreds of uses of "if verbose".
To contact Technical Support use the Contact Us link on http://www.mathworks.com
- Prev by Date: Re: semi-colon suppress output of user defined function
- Next by Date: Simple question: How can I access the second y axis (and x axis) for plotyy
- Previous by thread: Re: semi-colon suppress output of user defined function
- Next by thread: Re: semi-colon suppress output of user defined function