Matlab如何实现多维变量的无约束最优化问题

2025-01-01 19:05:26
推荐回答(1个)
回答1:

举个例子:

m1 = 1; n1 = 2; n2 = 3; m0 = 4; c = 5; n0 = 6; r = 7;

myfun = @(x) (m1*(n1+n2)+m0*c*x(1)/x(2)+r*x(1)*x(2)*n1+r*n0*x(1)^2/2);

x0 = [1 1];

[x,fval] = fminunc(myfun,x0);

clc;

x

fval