I don't know why Matlab doesn't do this, but if no output arguments are assigned for a function, I would prefer my functions not to output to the console.
E.g.
function out=getmagic(n)
out=magic(n);
figure;
plot(out(1,:));
end
For high numbers this is increasingly more annoying if you forget the ;
mark at the end of the line when calling the function. My solution so far is to include an if
statement at the end of the function:
if nargin==0 %no output argument is requested
out=[]; %shorten ouput argument to prevent flooding of console
end
is there any better way of doing this (e.g. wouldn't give any output at all)?