MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [求助]运行matlab函数时出现的问题求解 (https://www.labfans.com/bbs/showthread.php?t=5027)

niesanshi 2008-10-27 15:31

[求助]运行matlab函数时出现的问题求解
 
各位大虾,我是一个matlab超级初入门的新手,今天对着书写了个函数,但是在运行时出现了下面的问题,请大家帮我解决一下啊!
function out=check_arg(a,b,c)
%Example 5-3:check_arg
%check_arg(a,b,c),the return walue is decided by the function
%input number and input arguments
if(nargin==1)
out=a;
elseif(nargin==2)
out==(a.^2+b.^2);
elseif(nargin==3)
out==(a*b*c\2);
end
这样一个函数在command 里运行时,出现
>> exp53(10)
??? Undefined function or method 'exp53' for input arguments of type 'double'.
多谢各位大虾了!:confused:

Juicy 2008-10-27 21:10

回复: [求助]运行matlab函数时出现的问题求解
 
if nargin==1
out = a;
elseif nargin==2
out = a.^2+b.^2;
else nargin==3
out = a.*b.*c/2;
end

mathjiang 2008-10-27 21:22

回复: [求助]运行matlab函数时出现的问题求解
 
问题应该是你没有else

mathjiang 2008-10-27 21:25

回复: [求助]运行matlab函数时出现的问题求解
 
还有就是,你的函数名是check_arg,怎么在命令窗口输入exp53(10),何意?

niesanshi 2008-11-04 09:10

回复: [求助]运行matlab函数时出现的问题求解
 
多谢大虾了,我还以为是要输入函数所在的文件名呢,不好意思哈!


所有时间均为北京时间。现在的时间是 05:07

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.