Integration of anonymous functions using fmincon

조회 수: 2 (최근 30일)
je deers
je deers 2019년 10월 9일
Dear all,
I want to find the maximum area of a function subject to some constraints using fmincom.
Here is my code
b_method = [1/2, 1/2];
a_method = [0,0;1,0];
dim = size(a,1)
%the area of the function is expressed as..
R=@(c)integral(@(z) 1+[z(1) z(2)].*b_method.*inv(eye(dim)-[z(1) z(2)].*a_method).*ones(dim,1),'ArrayValued', true);
%starting point
x0 = [-1,-1];
%p=1 constraints
a_c = [1,0;0,1];
b_c = [1;1];
x = fmincon(R,x0,a_c,b_c)
I am very new with using fmincon and this is the error I am getting
Error using integral (line 85)
A and B must be floating-point scalars.
Error in
maximize>@(c)integral(@(z)1+[z(1),z(2)].*b.*inv(eye(dim)-[z(1),z(2)].*a).*ones(dim,1),'ArrayValued',true)
Error in fmincon (line 552)
initVals.f = feval(funfcn{3},X,varargin{:});
Error in maximize (line 22)
x = fmincon(R,x0,a_c,b_c)
Caused by:
Failure in initial objective function evaluation. FMINCON cannot continue.
I am not sure where the error is coming from, any help would be appreciated.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by