matlab求多元函数最小值,f=sin(x1)+sin(x2);其中x1+x2=3且都是正数,我

matlab求多元函数最小值,f=sin(x1)+sin(x2);其中x1+x2=3且都是正数,我只要matlab程序,多谢了

用fmincon求解即可:

>> x=fmincon(@(x)sin(x(1))+sin(x(2)),[1 1],[],[],[1 1],3,[0 0])
Local minimum possible. Constraints satisfied.
fmincon stopped because the size of the current step is less than
the default value of the step size tolerance and constraints are 
satisfied to within the default value of the constraint tolerance.
<stopping criteria details>

x =
    1.5000    1.5000

也可以绘图加以验证:

ezcontour(@(x1,x2)sin(x1)+sin(x2),[0 3])
hold on
ezplot('x1+x2=3')
x=fmincon(@(x)sin(x(1))+sin(x(2)),[1 1],[],[],[1 1],3,[0 0]);
plot(x(1),x(2),'ro')

温馨提示:答案为网友推荐,仅供参考
相似回答