1、 分别画出级联法、并联法的系统模拟结构图及其状态方程和输出方程,图式如下:状态方程:输出方程:使用龙格库塔法程序进行仿真,令u=1,系统在t=0-2s之间(仿真步长0.1s)则输出y截图如下: 比较后发现两者仿真结果接近。二、(20分)已知系统的状态方程及输出方程 拟用四阶龙格-库塔法求系统在t=0-2s之间的输出值(仿真步长取0.01s或0.1s),试编写仿真程序,对仿真结果截图。(单号C+,双号VB)答:用c+进行四阶龙格-库塔法,系统在t=0-2s间的(仿真步长0.01)编程:#includecstringusing namespace std;float x1;float x2;flo
2、at x3;float x4;float t;float f1(float x1,float x2,float x3,float x4,float t) float f1; return f1=3*x1+2*x2-x3;float f2(float x1,float x2,float x3,float x4,float t) float f2; return f2=2*x1-x2+2*x3;float f3(float x1,float x2,float x3,float x4,float t) float f3; return f3=x1+2*x2-x3+2;float f4(float x
3、1,float x2,float x3,float x4,float t) float f4; return f4=0;int main() float k11,k12,k13,k14,k21,k22,k23,k24,k31,k32,k33,k34,k41,k42,k43,k44; float t=0,h=0.01; double y; float x1=0,x2=0,x3=0,x4=0; for(int i=1;i200;i+) t=t+h; k11 = h * f1(x1, x2, x3, x4, t); k21 = h * f2(x1, x2, x3, x4, t); k31 = h *
4、 f3(x1, x2, x3, x4, t); k41 = h * f4(x1, x2, x3, x4, t); k12 = h * f1(x1 + k11 / 2, x2 + k21 / 2, x3 + k31 / 2, x4 + k41 / 2, t + h / 2); k22 = h * f2(x1 + k11 / 2, x2 + k21 / 2, x3 + k31 / 2, x4 + k41 / 2, t + h / 2); k32 = h * f3(x1 + k11 / 2, x2 + k21 / 2, x3 + k31 / 2, x4 + k41 / 2, t + h / 2);
5、k42 = h * f4(x1 + k11 / 2, x2 + k21 / 2, x3 + k31 / 2, x4 + k41 / 2, t + h / 2); k13 = h * f1(x1 + k12 / 2, x2 + k22 / 2, x3 + k32 / 2, x4 + k42 / 2, t + h / 2); k23 = h * f2(x1 + k12 / 2, x2 + k22 / 2, x3 + k32 / 2, x4 + k42 / 2, t + h / 2); k33 = h * f3(x1 + k12 / 2, x2 + k22 / 2, x3 + k32 / 2, x4
6、 + k42 / 2, t + h / 2); k43 = h * f4(x1 + k12 / 2, x2 + k22 / 2, x3 + k32 / 2, x4 + k42 / 2, t + h / 2); k14 = h * f1(x1 + k13, x2 + k23, x3 + k33, x4 + k43, t + h); k24 = h * f2(x1 + k13, x2 + k23, x3 + k33, x4 + k43, t + h); k34 = h * f3(x1 + k13, x2 + k23, x3 + k33, x4 + k43, t + h); k44 = h * f4
7、(x1 + k13, x2 + k23, x3 + k33, x4 + k43, t + h); x1 = x1 + (k11 + 2 * k12 + 2 * k13 + k14) / 6; x2 = x2 + (k21 + 2 * k22 + 2 * k23 + k24) / 6; x3 = x3 + (k31 + 2 * k32 + 2 * k33 + k34) / 6; y=x1+2*x2-2*x3;couty=y= 0.5 Thenn = n + 1End IfIf 0.4 = n / 25 = 0.9 Thens = s + 1Text1.Text = s如下:5、(20分)某自?市?,平均每分?有6位?客到?,每位?客?物?服?(4.2,7.2)分?均布(不包括交?)。有十?收?台,每位?客服?(1.2,2)分?均布。用GPSS?其排?情?要求?出?模型的程序?,列出程序?,?4000-5000次) 程序?及程序? SIMULATE 1 STORAGE 10 GENERATE 1/6,0 ADVANCE 5.7,1.5 QUEUE 1 ENTER 1 DEPART 1 MARK ADVANCE 1.6,.4 LEAVE 1 TABULATE 1 TERMINATE 1 1 TABLEIA,5,5,10 START 4000 END
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1