getting error of not enough input argument?
1 次查看(过去 30 天)
显示 更早的评论
I am trying to run this code from my command window (gumbelfit(Y), however, i get error, that there is error in line 7 (my line seven is when it calculates f). but when i run this from the function window itself it says that there is not enough argument (Line-2). Can somebody help me with this?
function [P] = gumbelfit(Y)
Me=mean(Y);
De=std(Y);
A=sqrt(6).*De./pi;
B=Me-0.45.*De;
f=gumbelpdf(Y,A,B);
F=gumbelcdf(Y,A,B);
X=gumbelinv(F,A,B);
YS=sort(Y);
Pd=gumbelpdf(YS,A,B);
plot(YS,pd,lineweight,25);
end
7 个评论
Adam
2014-9-24
gumblepdf is the function giving the error when called with 3 arguments though, not gumblefilt
回答(3 个)
Iain
2014-9-24
gumbelpdf, gumbelcdf, gumbelinv are all functions that we don't have, so we can only say how to fix your error properly
gumbelpdf can probably only accept 1 or 2 inputs. You are supplying three. You need to modify your code so that you use gumbelpdf correctly.
0 个评论
John D'Errico
2014-9-24
编辑:John D'Errico
2014-9-24
From what you are saying, it sounds as if you you are trying to run a function from the editor, as if it was a script. This is not possible, as matlab does not know what to pass into the function. (Note, IF the function has no input arguments at all, then it can be done.)
So, for example, if I write the function below and save it, then try to "Run" it from the function editor as if it were a script...
function testme
disp('the sky is falling')
then I get the output:
>> testme
the sky is falling
This works, because testme can be executed like a script, although as a function it has its own private workspace.
However, change it so that the function has an input argument, and NOW try to run it...
function testme(Y)
disp(Y)
As you see, the function expects to see an input argument Y here, and none was supplied.
>> testme
Error using testme (line 2)
Not enough input arguments.
Functions are designed to be used as functions, not as scripts. See that when you use the "run" capability of the editor, which is a capability that has been around since time began, it tries to execute the file at the command line. But as you can see, it passed in no arguments. This is why you got the error you did.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Debugging 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!