필터 지우기
필터 지우기

Constraints problem using fmincon

조회 수: 1 (최근 30일)
Jhon Dukester
Jhon Dukester 2014년 4월 6일
편집: Matt J 2014년 4월 9일
%Matrix 150 by 7
dataN=[A2 B2 C2 D E2 F2 G];
V=cov(dataN);
X=ones(7,1);
R=mean(dataN,1)';
lb=repmat(0,size(X));
ub=repmat(0.4,size(X));
Aeq=ones(1,7);
beq=1;
x0=ones(7,1)/7;
options = optimoptions(@fmincon,'Algorithm','interior-point')
[X,fval] = fmincon(@(X)-mean(X'*R),x0,[],[],Aeq,beq,lb,ub,@mycon,options)
function [c,ceq] = mycon(X)
global V
global X
c=0;
ceq=X'*V*X-1
end
My problem is my code does not respect my constraint ceq, any idea?
Thank you
  댓글 수: 2
Alan Weiss
Alan Weiss 2014년 4월 7일
편집: Alan Weiss 2014년 4월 7일
It would be much easier to read your question if you would format it using the { }Code button.
And you will probably be happier overall if you get rid of global variables and use another method to pass extra parameters.
Alan Weiss
MATLAB mathematical toolbox documentation
Jhon Dukester
Jhon Dukester 2014년 4월 9일
Thank you.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by