Matlab关于nargin和nargout函数程序不能正常运行
function =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 =mytest(x1,x2)
|
Error: Function definitions are not permitted at the prompt or in scripts.
请大家帮忙看看,谢谢 函数要定义在M文件中,不要在命令窗口输入! jiayou!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11
页:
[1]