"Not enough input arguments"

31 ビュー (過去 30 日間)
Prachi  Singh
Prachi Singh 2016 年 5 月 10 日
回答済み: Walter Roberson 2016 年 5 月 10 日
I am trying to run the below code -
--------------------
%Code:
p_initial = [0.1, 0.1, 0.1, 0.1];
options = optimoptions(@fmincon,'Display','iter','Algorithm','interior-point');
[p,fval] = fmincon(@tryone,p_initial,[],[],[],[],[],[],@errors,options)
It calls for 2 functions which are mentioned below :
%p(1), p(2) are Weibull shape parameters & p(3) is line intercept parameter, p(4) is slope parameter
function val=tryone(p,xdata, ydata)
p = [p(1), p(2), p(3), p(4)];
val = -sum(log(p(1))) -sum(log(p(2))) -(p(2)-1)*sum(log(ydata - p(3) - p(4)*xdata))+ p(1)*sum((ydata - p(3) - p(4)*xdata).^p(2));
%Constraint for Weibull errors to be positive
function [c, ceq] = errors(p,xdata,ydata)
c = ydata - p(3) - p(4)*xdata;
ceq = [ ];
---------------------------------------
I am encountering few problems:
1) I don't know how to incorporate constraint for Weibull parameters to be positive, i.e. p(1) and p(2) to be positive.
2) I am getting an error "Not enough input arguments" for this command (loglikelihood function mentioned above) -
val = -sum(log(p(1))) -sum(log(p(2))) -(p(2)-1)*sum(log(ydata - p(3) - p(4)*xdata))+ p(1)*sum((ydata - p(3) - p(4)*xdata).^p(2));
I am trying to run the below code -
---------------------------------------
Can somebody please tell me how to fix this?

採用された回答

Walter Roberson
Walter Roberson 2016 年 5 月 10 日

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by