0

I need to call a function that generates much output. Because the function is pretty delicate, I cannot go in and edit it. In this scenario, is it possible for me to still suppress all its output?

I am expecting either to suppress it, something like

output off;
theFunctionThatPrintsOutput();
output on;

or to direct the output to a file, something like

theFunctionThatPrintsOutput() >> ./output.txt;
Sibbs Gambling
  • 19,274
  • 42
  • 103
  • 174
  • I have never heard of such an option. If you have access to the source then it should be pretty easy -- even automatable -- to convert any calls to `disp` to `fprintf` and to set any `fprintf` calls to accept a file ID (set to `1` for the command window or `fh = fopen(name,'w+')` to write to a file. – transversality condition Aug 10 '15 at 04:15

1 Answers1

2

I would have added this as a comment because it is not technically my answer, but I do not have enough reputation to place comments just yet.

I believe that this is a duplicate question. It has already been answered here.

The accepted answer to that question should help answer your question.

I have taken the liberty of re-posting the important piece of cheshirekow's answer below:

[T,A,B,C] = evalc('notMyFunction(d,e,f);');

'T' will contain the output of that function that is suppressed by the 'evalc' function. '[A,B,C]' are variable outputs of the function.

Best of luck with your project!

Community
  • 1
  • 1
Vladislav Martin
  • 1,504
  • 2
  • 15
  • 34