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)的具体式子,请问应该怎么办?
​小弟初学优化算法,还请各位大虾多多指教~~

 Accepted Answer

hacic
hacic on 24 Nov 2022

0 votes

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);

More Answers (0)

Categories

Find more on 编程 in Help Center and File Exchange

Tags

Asked:

on 24 Nov 2022

Answered:

on 24 Nov 2022

Community Treasure Hunt

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

Start Hunting!