switching output based on input
이전 댓글 표시
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
답변 (1개)
Azzi Abdelmalek
2013년 10월 2일
0 개 추천
You can use if else statement
댓글 수: 6
Dany
2013년 10월 2일
Azzi Abdelmalek
2013년 10월 2일
This is not clear. Please give an example
Dany
2013년 10월 2일
Azzi Abdelmalek
2013년 10월 2일
Look at
help varargin
help varargout
help nargout
Dany
2013년 10월 2일
Azzi Abdelmalek
2013년 10월 2일
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)
카테고리
도움말 센터 및 File Exchange에서 Downloads에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!