《转向梯形优化设计matlab程序(共3页).doc》由会员分享,可在线阅读,更多相关《转向梯形优化设计matlab程序(共3页).doc(3页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精选优质文档-倾情为你奉上优化计算MATLAB程序首先,将目标函数写成M文件,其程序语句如下;function f = fun (x)global K L thetamax alphafor i=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)+a
2、lpha(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;if alpha(i)=pi/18,alpha(i)=pi/9;f(i)=abs(betaa(i)-betae3(i);elsef(i)=0.5*abs(beta(i)-betae3(i);global K L thetamax alphaK=inputL=inputthetamax=inputx0(1)=inputx0(2)=inputthetamax = thetamax*pi/180;x0(2)=x0
3、(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)g lobal K L thetamax alphaK = inputL= inputthetamax= inputx ( 1
4、) = inputx ( 2) = inputthetamax = thetamax * pi/ 180;x ( 2) = x ( 2) * pi/ 180;alpha= linspace( 0, thetamax , 61) ;fo r i= 161betae= 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)
5、+ 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) + sqr t ( ( ( 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); hold onplot ( alpha ( i) , beta( i) ,b)hold o ff专心-专注-专业