1个回答
展开全部
1、建立问题的数学模型:
2、matlab程序语言实现
2.1 先建立约束函数,保存为con_fun.m文件
function [c,ceq] = con_fun(x)
AB = sqrt(x(1).^2+x(2).^2);
AE = sqrt((x(1)-0.3).^2+(x(2)-1.0).^2);
BE = sqrt(1.09);
c = [];
ceq = (AB.^2+AE.^2-BE.^2)./(2.0*AE.*AB) - cos(10/180*pi);
2.2 然后使用fmincon()函数实现约束极值问题的求解
>> fun = @(x) sqrt((x(1)+1).^2+x(2).^2); % 目标函数
>> x0 = [1.0, 1.0]; % 假设的初始解
>> options = optimset('Algorithm','interior-point'); % 求解算法
>> [x,d]= fmincon(fun,x0,[],[],[],[],[],[],@con_fun,options)
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the function tolerance,
and constraints were satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
x =
-0.3397 -0.5291
d =
0.8461
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询