I want to suppress the output of variables in a set of Matlab functions. The problem is that the author forget the ";" at many positions in the code. For debug purpose this output is useful but now I want to suppress it, without searching the whole code for the missing ";". Is there a possibility to turn off this kind of output?
-
3Possible duplicate of this: [http://stackoverflow.com/questions/3029636/suppressing-a-functions-command-window-output-in-matlab](http://stackoverflow.com/questions/3029636/suppressing-a-functions-command-window-output-in-matlab) The answer was: "You might try wrapping the call to the function in an [evalc](http://www.mathworks.com/help/techdoc/ref/evalc.html)." – david.s Mar 01 '12 at 15:17
4 Answers
You can suppress the output using evalc, but this requires you to pass your expression in as a string. For instance if you were using:
[A,B,C] = notMyFunction(d,e,f);
You can use instead
[T,A,B,C] = evalc('notMyFunction(d,e,f);');
And any output that would have gone to the console will now be buffered and stored in T
.

- 4,797
- 6
- 43
- 47
What about calling those functions with a semicolon at the end? So instead of calling
my_function()
simply type
my_function();
Edit: http://www.mathworks.de/help/techdoc/ref/evalc.html evalc('my_function()');
Edit2: Too late

- 9,896
- 20
- 81
- 137
-
This is wrong. Adding the semicolon prevents printing the return value(s). It doesn't change anything about the behavior of the function. – Ronenz Aug 11 '16 at 04:03
Sorry, but there is no simple way to just turn off the display to the command window when you fail to add semi-colons. Just add the semi-colons yourself.
Yes, you could overload disp and display, preventing them from working as they are supposed to do, but then they would fail to work under normal circumstances also. You would be breaking a valuable part of matlab.
And sorry, but adding a semi-colon to the end of a function call has no impact on whether internal lines have no semi-colons. Those internally unterminated lines will still dump their results to the command window.
when calling the function, you need to put a sign " ; " at the end, otherwise the output would be displayed, no matter for user function or matlab-pre-defined functions.

- 9
-
The question was not to suppress the output of the return values of a function call. The question was to suppress the output of all nested function calls that might miss the ; sign. Therefore the `evalc` is the answer. – M.K. aka Grisu Oct 19 '15 at 11:37