getting error of not enough input argument?

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

Could you please provide us the header line of gumbelpdf?
I didnt understand your question, however, I am trying to find parameter of the gumbel distribution through the method of moments as mentioned (A & B) and then i need to program those functions (f,F & X) so that can be called with a vector argument P or Y).
Hope this helps
Where did you get the functions you are using? They do not exist in MATLAB version R2014a, or in the File Exchange.
The Extreme Value Distrbution can also be called the Gumble distribution, but that is as close as MATLAB gets to it in the online documentation.
We had lecture on this and now assignment where we need to built this function. I need to call the function from command window where i shall get the plot and parameter value.
If you are building the function yourself is it not obvious based on how you have programmed it how many arguments it should take vs how many arguments you are calling it with?
Just one input (Y) which is my flow data and am calling it with only one argument (gumbelfit(Y);) in the window
gumblepdf is the function giving the error when called with 3 arguments though, not gumblefilt

Sign in to comment.

Answers (3)

Iain
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.
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.
Hydro
Hydro on 24 Sep 2014
Thank you all for your feedback,
I sort it out..i basically asked the question in not a clear way. i need to create three other function for f,F & X. These function are called within the function are put up.
Cheers,

Asked:

on 24 Sep 2014

Answered:

on 24 Sep 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!