子函数:
function [y1,y2]=mytestio(x1,x2)
if nargin==1 %确定函数调用时实际输入的参数个数
y1=x1;
if nargout==2
y2=x1;
end
else
if nargout==1
y1=x1+x2;
else
y1=x1;
y2=x2;
end
end
>> x=mytestio(5)
x =
5
>> [x,y]=mytestio(5)
x =
5
y =
5
>> x=mytestio(5,7)
x =
12
>> [x,y]=mytestio(5,7)
x =
5
y =
7
>> mytestio(5,7)
ans =
5