getting error of not enough input argument?
2 views (last 30 days)
Show older comments
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 Comments
Adam
on 24 Sep 2014
gumblepdf is the function giving the error when called with 3 arguments though, not gumblefilt
Answers (3)
Iain
on 24 Sep 2014
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 Comments
John D'Errico
on 24 Sep 2014
Edited: John D'Errico
on 24 Sep 2014
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 Comments
See Also
Categories
Find more on Debugging in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!