马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
matlab下,我用fminsearch求得的是局部极小值,且在给出的初始点附近,初始值的选取影响太大。请各位高手大侠们给指点下,如何求得全局极小值?
代码如下:
l=[991.7843 863.0463 802.1390 848.0684 818.4741 947.4123 886.3842 998.2794];
c=3*10^8;
for j=1:8
t(j)=l(j)/c;
end
R=850;
r=100;
for j=1:8
cosq(j)=(R^2-r^2+(t(j)*c-r)^2)/(2*(t(j)*c-r)*R);
end
f=@(R)(-((t(1)*c)^2-R^2)*(R^2*c+(t(1)*c)^3-2*t(1)*c^2*R*cosq(1))/(8*pi*100*(R*cosq(1)-t(1)*c)^3))*(((t(2)*c)^2-R^2)*(R^2*c+(t(2)*c)^3-2*t(2)*c^2*R*cosq(2))/(8*pi*100*(R*cosq(2)-t(2)*c)^3))*(((t(3)*c)^2-R^2)*(R^2*c+(t(3)*c)^3-2*t(3)*c^2*R*cosq(3))/(8*pi*100*(R*cosq(3)-t(3)*c)^3))*(((t(4)*c)^2-R^2)*(R^2*c+(t(4)*c)^3-2*t(4)*c^2*R*cosq(4))/(8*pi*100*(R*cosq(4)-t(4)*c)^3))*(((t(5)*c)^2-R^2)*(R^2*c+(t(5)*c)^3-2*t(5)*c^2*R*cosq(5))/(8*pi*100*(R*cosq(5)-t(5)*c)^3))*(((t(6)*c)^2-R^2)*(R^2*c+(t(6)*c)^3-2*t(6)*c^2*R*cosq(6))/(8*pi*100*(R*cosq(6)-t(6)*c)^3))*(((t(7)*c)^2-R^2)*(R^2*c+(t(7)*c)^3-2*t(7)*c^2*R*cosq(7))/(8*pi*100*(R*cosq(7)-t(7)*c)^3))*(((t(8)*c)^2-R^2)*(R^2*c+(t(8)*c)^3-2*t(8)*c^2*R*cosq(8))/(8*pi*100*(R*cosq(8)-t(8)*c)^3));
[y,n]=fminsearch(f,900);%求y
结果是:y =864.6721
当输入的是 [y,n]=fminsearch(f,850);时y= 847.8084
当初始值分别设为700, 750, 800, 850,900, 950时发现结果分别为:
864.6721,864.6721,847.8084,847.8084,864.6721,1.0033e+003
|