Error using fmincon, row dimension inconsistent

2 次查看(过去 30 天)
How to fix the error:"not enough input arguments"? I want to use fmincon to minimize the function value. I have the function code : (also attached)
function [ likelihood_lou ] = MLE_lou( vix,par_lou )
%Calculate the log likelihood of log(Vt) under Gaussian Distribution
n = length(vix);
miu = zeros(n,1);
var = zeros(n,1);
L = zeros(n,1);
for i =1:n
miu(i)= par_lou(2)+exp(-par_lou(1)*(vix(i,7)/360))*(log(vix(i,8))-par_lou(2));
var(i)= (par_lou(3)^2)*(1-exp(-2*par_lou(1)*(vix(i,7)/360)))/(2*par_lou(1));
L(i) = (n/2)*log(var(i))+((log(vix(i,9))-miu(i))^2)/(2*var(i)); end
likelihood_lou = -sum(L);
end
and the fmincon function as: par_0 = [2.898,3.099,0.884];
para_lou = fmincon(MLE_lou,par_0,[],vix_in);
The error message:
Error using fmincon (line 291) Row dimension of A is inconsistent with length of b.
I want to ask how to solve this problem? Really thanks
  4 个评论
Yuhe Qin
Yuhe Qin 2018-7-30
n is not an input arguments, it is the number of data of input dataset
Jan
Jan 2018-7-30
Please post the complete error message. Most of all it would be useful to know, which line is failing.

请先登录,再进行评论。

回答(1 个)

Steven Lord
Steven Lord 2018-7-30
para_lou = fmincon(MLE_lou,par_0,[],vix_in);
This attempts to call the MLE_lou function with zero input arguments and pass the first output argument from that function call into fmincon as its first input. That's not going to work since your MLE_lou function requires two input arguments.
Pass a function handle to MLE_lou into fmincon instead.
para_lou = fmincon(@MLE_lou,par_0,[],vix_in);

类别

Help CenterFile Exchange 中查找有关 Nonlinear Optimization 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by