fmincon:Supplied objective function must return a scalar value.

조회 수: 1 (최근 30일)
Ylenia Placella
Ylenia Placella 2020년 11월 15일
댓글: Ylenia Placella 2020년 11월 15일
%constraints c and ceq
for h=linspace(h_min,h_max,69);
x=zeros(N,1);
c=h-x(1)'*D*x(2);
end
function [c,ceq]= contr (x)
ceq=[];
c=c;
end
%function to optimize
[T,N]=size(RR)
629 69
f=@(x)x(1)'*sigma*x(2);
nonlcon=@contr;
Aeq=ones(1,N);
beq=1;
l_b=[];
u_b=[];
x0=ones(N,1);
A=[];
b=[];
sigma_2rao = zeros(1,length(h));
sigma_2rao(1)=var_min;
x_rao=zeros(N,length(h));
for h=linspace(h_min,h_max,69)
[x_rao(:,h),sigma_2rao(h)] = fmincon(f,x0,A,b,Aeq,beq,l_b,u_b,nonlcon);
end
  댓글 수: 4
Ylenia Placella
Ylenia Placella 2020년 11월 15일
I changed the codes like you said.
Now I have this error:
Unrecognized function or variable 'contr'.
Error in fmincon (line 649)
[ctmp,ceqtmp] =
feval(confcn{3},X,varargin{:});
Error in funzionerao_14 (line 15)
[x_rao(:,h),sigma_2rao(h)] =
fmincon(f,x0,A,b,Aeq,beq,l_b,u_b,nonlcon);

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Surrogate Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by