How can I suppress the 'ans' output?
50 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponse acceptée
Sagar Damle
le 19 Avr 2013
Modifié(e) : Matt J
le 19 Avr 2013
Use this function :-
function summie( x,y )
z=x+y;
disp(['The summie is: ', num2str(z)])
end
That is, do not send 'z' as output. In other words,return type of your function should be 'void' to suppress the 'ans' output. Search this PDF on internet –
POLYTECHNIC UNIVERSITY Department of Financial and Risk Engineering User-Defined Functions in Matlab K. Ming Leung
2 commentaires
Matt J
le 19 Avr 2013
I think you meant to thank Sagar. However, consider also my solution with varargout. It is similar to Sagar's solution, but allows you to continue to have an optional output argument.
Voir également
Catégories
En savoir plus sur Image Processing and Computer Vision dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!