function [y1,y2]=mytest(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
这个程序是关于函数调用时实际的输入和输出参数个数,结合条件分支语句就可以处理函数调用中指定不同数目的输入输出参数的情况。
这个程序应该没有问题但是报错
function [y1,y2]=mytest(x1,x2)
|
Error: Function definitions are not permitted at the prompt or in scripts.
请大家帮忙看看,谢谢