I have a short function which uses textscan to read data into a variable.
My problem is that I always get this:
>>function(\'funct
The simplest way to avoid having output printed out is to not assign the first output argument if no output argument was requested:
function [aOut,b,c] = doSomething
%# create a,b,c normally
a = 1;
b = 4;
c = 3;
%# only assign aOut if any output is requested
if nargout > 0
aOut = a;
end
You can suppress the output by remove output arguments (or return values) of the function.
OR
Try use Variable Number of Outputs, see Support Variable Number of Outputs
function varargout = foo
nOutputs = nargout;
varargout = cell(1,nOutputs);
for k = 1:nOutputs;
varargout{k} = k;
end
end
You type >>foo and get nothing.
You type >>a=foo and get >>a=1.
You type >>[a,b]=foo and get >>a=1 >>b=2.
You can thus suppress output by NOT providing any output arguments.
You could try using the diary functionality. It redirects all input and output from the command prompt to a file of your choice. If you only turn it on during a specific function, no input should be captured.
I admit it is a bit of a clumsy solution as the diary on/off state is global to matlab, but it might be ok in your case.
Read more about it here: Diary matlab help