Filter löschen
Filter löschen

switching output based on input

2 Ansichten (letzte 30 Tage)
Dany
Dany am 2 Okt. 2013
Kommentiert: Azzi Abdelmalek am 2 Okt. 2013
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

Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 2 Okt. 2013
You can use if else statement
  6 Kommentare
Dany
Dany am 2 Okt. 2013
ok, thank you.
Azzi Abdelmalek
Azzi Abdelmalek am 2 Okt. 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)

Melden Sie sich an, um zu kommentieren.

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by