How can I suppress the 'ans' output?
Mostra commenti meno recenti
When my code looks like this
function [ z ] = summie( x,y )
z=x+y;
disp(['The summie is: ', num2str(z)])
end
and I typ in the command window for example
summie(1,2)
This is displayed:
The summie is: 3
ans =
3
Is there a way to suppress the 'ans' output, so that only
The summie is: 3
is displayed?
Risposta accettata
Più risposte (1)
Matt J
il 18 Apr 2013
Add a semicolon to the end of the function call
sum(1,2);
4 Commenti
Matt J
il 18 Apr 2013
Incidentally, it is a bad idea to call your function "sum", since this will conflict with MATLAB's native SUM command.
Matt J
il 19 Apr 2013
function varargout = summie( x,y )
z=x+y;
disp(['The summie is: ', num2str(z)])
if nargout
varargout{1}=z;
end
end
Jeroen
il 19 Apr 2013
Categorie
Scopri di più su Scope Variables and Generate Names in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!