"Not enough input arguments"

조회 수: 24 (최근 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 CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by