matlab转向梯形优化设计,转向梯形优化设计matlab程序

优化计算MATLAB程序

首先,将目标函数写成M文件,其程序语句如下; function f = fun (x) global K L thetamax alpha for i=1:61 f = 0

betae = 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; if alpha(i)<=pi/18

f(i)=1.5*abs(beta(i)-betae3(i));

elseif alpha>=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 alpha K=input L=input thetamax=input x0(1)=input

x0(2)=input

thetamax = 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) g lobal K L thetamax alpha K = input L= input

thetamax= input x ( 1) = input x ( 2) = input

thetamax = thetamax * pi/ 180; x ( 2) = x ( 2) * pi/ 180;

alpha= linspace( 0, thetamax , 61) ; fo r i= 1∶61

betae= 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) + sqr t ( ( ( A( i) ) .∧2+( B( i) ) . ∧2- * ( C( i) ) . ∧2) ) /( B( i) + C( i) ) ) ; beta( i) = x ( 2) + theta3( i) - pi; end

plot ( alpha( i) , betae( i ) ,‘r’); hold on

plot ( alpha ( i) , beta( i) ,‘b’) hold o ff

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值