n=linspace(600,4000,100);%均分计算指令,600最低转速,4000最高转速,均分为100等分r=0.367;i0=5.83;nt=0.85;G=3880*9.8;f=0.013;CDA=2.77;If=0.218;Iw1=1.798;Iw2=3.598;m=3880;L=3.2;a=1.947;hg=0.9;ig=[6.09,3.09,1.71,1.00];%输入已知参数ua1=0.377*r*n/i0/ig(1);ua2=0.377*r*n/i0/ig(2);ua3=0.377*r*n/i0/ig(3);ua4=0.377*r*n/i0/ig(4);%各转速各挡位下的速度Tq=-19.313+295.27*(n/1000)-165.44*(n/1000).^2+40.874*(n/1000).^3-3.8445*(n/1000).^4;%从600~4000rpm油拟合公式计算发动机转距Ft1=Tq*i0*ig(1)*nt/r;Ft2=Tq*i0*ig(2)*nt/r;Ft3=Tq*i0*ig(3)*nt/r;Ft4=Tq*i0*ig(4)*nt/r;%从600~4000rpm各挡位的驱动力Ff=G*f;ua=linspace(0,200,100);Fw=CDA*ua.*ua/21.15;%空气阻力plot(ua1,Ft1,ua2,Ft2,ua3,Ft3,ua4,Ft4,ua,Ff+Fw);%画出各挡位的Ua-Ft,及Ua-Ff+Ftxlabel('ua/km/h');ylabel('F/N');%标注横纵轴title('汽车驱动力-行驶阻力平衡图');%标注图形题目gtext('Ft1'),gtext('Ft2'),gtext('Ft3'),gtext('Ft4'),gtext('Ff+Fw');%给每根线条添加符号legend('Ft1','Ft2','Ft3','Ft4','Ff+Fw');%标注图例umax=max(ua4);disp('汽车最高车速=');disp(umax);disp('km/h');imax=tan(asin(max((Ft1-(Ff+Fw))/G)));%最大爬坡度的公式disp('汽车最大爬坡度=');disp(imax);%输出最高车速,与最大爬坡度的结果n=600:1:4000;%600最低转速,4000最高转速,相邻数组间隔1r=0.367;i0=5.83;eff=0.85;f=0.013;CdA=2.77;m=3880;g=9.8;%输入已知参数G=m*g;Ttq=-19.313+295.27*n/1000-165.44*(n/1000).^2+40.874*(n/1000).^3-3.8445*(n/1000).^4;%从600~4000rpm油拟合公式计算发动机转距forig=[6.09,3.09,1.71,1.00]Ua=0.377*r*n/ig/i0;%各转速各挡位下的速度Pe=Ttq.*n/9550;%各转速下的功率plot(Ua,Pe);holdon;%使当前轴及图形保持而不被刷新,准备接受此后将绘制的图形,多图共存endUa=0:0.1:max(Ua);Pf=G*f*Ua/3600;%滚动阻力Pw=CdA*Ua.^3/76140;%空气阻力plot(Ua,(Pf+Pw)/eff);title('汽车的功率平衡图'),xlabel('Ua/(km/h)'),ylabel('P/kw');%画出汽车的功率平衡图gtext('Ft1'),gtext('Ft2'),gtext('Ft3'),gtext('Ft4'),gtext('(Pf+Pw)/nt');legend('Ⅰ','Ⅱ','Ⅲ','Ⅳ','Pf+Pw/nt');n=600:1:4000;%600最低转速,4000最高转速,相邻数组间隔r=0.367;i0=5.83;nt=0.85;f=0.013;CdA=2.77;m=3880;g=9.8;%输入已知参数G=m*g;Ttq=-19.313+295.27*n/1000-165.44*(n/1000).^2+40.874*(n/1000).^3-3.8445*(n/1000).^4;%从600~4000rpm油拟合公式计算发动机转距forig=[6.09,3.09,1.71,1.00]Ua=0.377*r*n/ig/i0;Ft=Ttq*i0*ig*nt/r;Fw=CdA*Ua.^2/21.15;D=(Ft-Fw)/G%汽车动力因子公式plot(Ua,D);%画出汽车动力特性图holdon;%使当前轴及图形保持而不被刷新,准备接受此后将绘制的图形,多图共存endf=0.0076+0.000056*Ua%滚动阻力与速度之间的关系plot(Ua,f);%画出速度与滚动阻力图title('汽车动力特性图'),%给图加题目xlabel('Ua/(km/h)'),ylabel('D');gtext('Ⅰ'),gtext('Ⅱ'),gtext('Ⅲ'),gtext('Ⅳ'),gtext('f');legend('Ⅰ','Ⅱ','Ⅲ','Ⅳ','f');n=600:10:4000;%600最低转速,4000最高转速,相邻数组间隔10m=3880;g=9.8;nmin=600;nmax=4000;G=m*g;ig=[6,093.091.711.00];nT=0.85;r=0.367;f=0.013;CDA=2.77;i0=5.83;L=3.2;a=1.947;hg=0.9;If=0.218;Iw1=1.798;Iw2=3.598;%输入已知参数Tq=-19.313+295.27*(n/1000)-165.44*(n/1000).^2+40.874*(n/1000).^3-3.8445*(n/1000).^4;%从600~4000rpm油拟合公式计算发动机转距Ft1=Tq*ig(1)*i0*nT/r;Ft2=Tq*ig(2)*i0*nT/r;Ft3=Tq*ig(3)*i0*nT/r;Ft4=Tq*ig(4)*i0*nT/r;%各转速各挡位下的驱动力ua1=0.377*r*n/ig(1)/i0;ua2=0.377*r*n/ig(2)/i0;ua3=0.377*r*n/ig(3)/i0;ua4=0.377*r*n/ig(4)/i0;%各挡位各转速下的速度Fw1=CDA*ua1.^2/21.15;Fw2=CDA*ua2.^2/21.15;Fw3=CDA*ua3.^2/21.15;Fw4=CDA*ua4.^2/21.15;%不同速度下的空气阻力Ff=G*f;deta1=1+(Iw1+Iw2)/(m*r^2)+(If*ig(1)^2*i0^2*nT)/(m*r^2);deta2=1+(Iw1+Iw2)/(m*r^2)+(If*ig(2)^2*i0^2*nT)/(m*r^2);deta3=1+(Iw1+Iw2)/(m*r^2)+(If*ig(3)^2*i0^2*nT)/(m*r^2);deta4=1+(Iw1+Iw2)/(m*r^2)+(If*ig(4)^2*i0^2*nT)/(m*r^2);%不同挡位下的汽车旋转质量换算系数a1=(Ft1-Ff-Fw1)/(deta1*m);ad1=1./a1;a2=(Ft2-Ff-Fw2)/(deta2*m);ad2=1./a2;a3=(Ft3-Ff-Fw3)/(deta3*m);ad3=1./a3;a4=(Ft4-Ff-Fw4)/(deta4*m);ad4=1./a4;%各挡位下的加速度plot(ua1,ad1,ua2,ad2,ua3,ad3,ua4,ad4);title('汽车的加速度倒数曲线');xlabel('ua(km/h)');ylabel('1/a)');%作汽车加速度倒数曲线gtext('1/a1'),gtext('1/a2'),gtext('1/a3'),gtext('1/a4');legend('1/a1','1/a2','1/a3','1/a4');n=600:10:4000;m=3880;g=9.8;nmin=600;nmax=4000;G=m*g;ig=[6.093.091.711.00];nT=0.85;r=0.367;f=0.013;CDA=2.77;i0=5.83;L=3.2;a=1.947;hg=0.9;If=0.218;Iw1=1.798;Iw2=3.598;%输入已知参数Tq=-19.313+295.27*(n/1000)-165.44*(n/1000).^2+40.874*(n/1000).^3-3.8445*(n/1000).^4;%从600~4000rpm油拟合公式计算发动机转距Ft1=Tq*ig(1)*i0*nT/r;Ft2=Tq*ig(2)*i0*nT/r;Ft3=Tq*ig(3)*i0*nT/r;Ft4=Tq*ig(4)*i0*nT/r;%各转速各挡位下的驱动力ua1=0.377*r*n/ig(1)/i0;ua2=0.377*r*n/ig(2)/i0;ua3=0.377*r*n/ig(3)/i0;ua4=0.377*r*n/ig(4)/i0;%各挡位各转速下的速度Fw1=CDA*ua1.^2/21.15;Fw2=CDA*ua2.^2/21.15;Fw3=CDA*ua3.^2/21.15;Fw4=CDA*ua4.^2/21.15;%不同速度下的空气阻力Ff=G*f;i1=asin((Ft1-Ff-Fw1)/G);i2=asin((Ft2-Ff-Fw2)/G);i3=asin((Ft3-Ff-Fw3)/G);i4=asin((Ft4-Ff-Fw4)/G);%不同档位下的坡度plot(ua1,i1,ua2,i2,ua3,i3,ua4,i4);title('汽车的爬坡度图');xlabel('ua/(km*h^-1)');ylabel('i/%');%作汽车的坡度图gtext('Ⅰ'),gtext('Ⅱ'),gtext('Ⅲ'),gtext('Ⅳ');m=3880;g=9.8;r=0.367;nt=0.85;f=0.013;CdA=2.77;i0=5.83;pg=7.1;%汽油的重度取7.1N/Lig=[6.093.091.711];n=600:1:4000;n0=[8151207161420122603300634033804];B00=[1326.81354.71284.41122.91141.01051.21233.91129.7];B10=[-416.46-303.98-189.75-121.59-98.893-73.714-84.478-45.291];B20=[72.37936.65714.5247.00354.47632.85932.97880.71113];B30=[-5.8629-2.0553-0.51184-0.18517-0.091077-0.05138-0.047449-0.00075215];B40=[0.177680.0430720.00681640.00185550.000689060.000350320.00028230-0.000038568];%输入已知参数B0=spline(n0,B00,n);B1=spline(n0,B10,n);B2=spline(n0,B20,n);B3=spline(n0,B30,n);B4=spline(n0,B40,n);%使用三次样条插值,保证曲线的光滑连续ua3=0.377*r*n/ig(3)/i0;ua4=0.377*r*n/ig(4)/i0;%求出发动机转速范围内对应的3、4档车速Pe3=(m*g*f*ua3/3600+CdA*ua3.^3/76140)/0.85;Pe4=(m*g*f*ua4/3600+CdA*ua4.^3/76140)/0.85;%发动机功率fori=1:1:3401%用拟合公式求出各个燃油消耗率b3(i)=B0(i)+B1(i)*Pe3(i)+B2(i)*Pe3(i).^2+B3(i)*