matlab中fmi​ncon的fun是矩​阵运算怎么办?。

想用优化算法求解一个矩阵运算式子的最小值,上网看了有关fmincon的资料,发现fmincon中的fun式子一般都是能写出x1,x2表达式的,比如
function y = fun1(x)
y = x(1)-0.25*x(2)+0.6;
如果我的fun是一个矩阵运算如:
min (h2-G2*phi2)'*W2*(h2-G2*phi2)
subject to: phi2>0
其中h2,G2,W2已知,phi2是一个3*1的向量,无法写出包含phi2(i)的具体式子,请问应该怎么办?
​小弟初学优化算法,还请各位大虾多多指教~~

 채택된 답변

hacic
hacic 2022년 11월 24일

0 개 추천

function mf=min(phi2)
h2=[]; %你求出的值
G2=[]; %你求出的值
W2=[]; %你求出的值
mf=(h2-G2*phi2)'*W2*(h2-G2*phi2);
end
fun=@min;
A=[];
b=[];
Aeq=[];
beq=[];
lb=[0 0 0];
ub=[];
nonlcon=[];
x0=phi2; %初始值
options=optimset('Algorithm','interior-point');
[phi2_min,fval]=fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options);

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 非线性方程组에 대해 자세히 알아보기

태그

질문:

2022년 11월 24일

답변:

2022년 11월 24일

Community Treasure Hunt

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

Start Hunting!