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!