switching output based on input
Afficher commentaires plus anciens
Hi, is it possible to switch the output of a function based on the input that was given to the function? im talking about switching to diffderent number and types of output?
thank you
Réponses (1)
Azzi Abdelmalek
le 2 Oct 2013
0 votes
You can use if else statement
6 commentaires
Dany
le 2 Oct 2013
Azzi Abdelmalek
le 2 Oct 2013
This is not clear. Please give an example
Dany
le 2 Oct 2013
Azzi Abdelmalek
le 2 Oct 2013
Look at
help varargin
help varargout
help nargout
Dany
le 2 Oct 2013
Azzi Abdelmalek
le 2 Oct 2013
Example
function varargout=ans_switch(a)
if a==1
varargout{1}=10
varargout{2}=20
else
varargout{1}=100
end
% to call this function
% If a==1
[out1,out2]=ans_switch(1)
% If a~=1
out1=ans_switch(12)
Catégories
En savoir plus sur Downloads dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!