转向梯形优化设计matlab程序

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

优化计算MATLAB程序首先,将目标函数写成M文件,其程序语句如下;functionf=fun(x)globalKLthetamaxalphafori=1:61f=0betae=atan(tan(alpha(i)/(1-(K/L)*tan(alpha(i))));A(i)=2*x(1).^2*sin(x(2)+alpha(i));B(i)=2*K*x(1)-2*x(1).^2*cos(x(2)+alpha(i));C(i)=2*x(1).^2-4*x(1).^2*(cos(x(2)).^2+4*K*x(1)*cos(x(2))-2*K*x(1)*cos(x(2)+alpha(i));theta3(i)=2*acot((A(i)+sqrt(A(i).^2+B(i).^2-C(i).^2))/(B(i)+C(i)));beta(i)=x(2)+theta3(i)-pi;ifalpha(i)=pi/18f(i)=1.5*abs(beta(i)-betae3(i));elseifalpha=pi/18,alpha(i)=pi/9;f(i)=abs(betaa(i)-betae3(i));elsef(i)=0.5*abs(beta(i)-betae3(i));globalKLthetamaxalphaK=inputL=inputthetamax=inputx0(1)=inputx0(2)=inputthetamax=thetamax*pi/180;x0(2)=x0(2)*pi/180;lb(1)=0.17K;lb(2)=0.17*K;ub(1)=acot(K/(1.2*L))ub(2)=pi/2;alpha=linspace(0,theamax,61);lb=[lb(1),lb(2)];ub=[ub(1),ub(2)];x(0)=[x0(1),x0(2)];options=optimset(‘TolFun’,‘le-10’,‘TolCon’,‘le-6’)[x,resnorm]=lsqnonlin(‘fun’,x0,lb,ub,options)globalKLthetamaxalphaK=inputL=inputthetamax=inputx(1)=inputx(2)=inputthetamax=thetamax*pi/180;x(2)=x(2)*pi/180;alpha=linspace(0,thetamax,61);fori=1∶61betae=atan(tan(alpha(i))/((1-K/L)*tan(alpha(i))));A(i)=2*(x(1)).∧2*sin(x(2)+alpha(i));B(i)=2*K*x(1)-2*(x(1)).∧2*cos(x(2)+alpha(i)));C(i)=2*(x(1)).∧2-4*(x(1)).∧2*(cos(x(2))).∧2+4*K*x(1)*cos(x(2))-2*K*x(1)*cos(x(2)+alpha(i));theta3(i)=2*acot(A(i)+sqrt(((A(i)).∧2+(B(i)).∧2-*(C(i)).∧2))/(B(i)+C(i)));beta(i)=x(2)+theta3(i)-pi;endplot(alpha(i),betae(i),‘r’);holdonplot(alpha(i),beta(i),‘b’)holdoff

1 / 3
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功