switching output based on input
3 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Azzi Abdelmalek
2013-10-2
You can use if else statement
6 个评论
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)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!