"Not enough input arguments"
24 views (last 30 days)
Show older comments
Prachi Singh
on 10 May 2016
Answered: Walter Roberson
on 10 May 2016
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?
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots 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!