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!