MATLAB: EVAL do not display OUTPUT

displayevalsemicolon

Hi all,
I am using eval function but even if I put semicolon ";" at the end of the line Matlab shows the output in the command window.
Is it possible to not display the result in the command window?

Best Answer

"I am using eval function but"
Don't use eval. It's one of those functions that's there but not to be used unless absolutely necessary, which is almost never. eval creates very inefficient, hard-to-debug codes.
For your case, use fprintf or disp to display variables you want. Otherwise, use the ";" to silence the output.
A = rand(3) %creates and shows A
A = rand(3); %silenced output for A
disp(A); %shows A
I am guessing you did something like this:
eval('A = rand(3)'); %Does not silence output for A = rand(3)
eval('A = rand(3);') %Silences output A = rand(3). But why bother using eval???