MATLAB实例源码教程:龙格库塔法求解微分方程组源代码实例.doc
MATLAB实例源码教程龙格库塔法求解微分方程组源代码实例题目用经典 Runge-Kutta方法求下列一阶微分方程组的近似解y1 3y1 2y2 2x2 1e2x, y10 1 e2x表示 exp(2*x)y2 4y1 y2 x2 2x 4e2x, y20 1 y3 2y1 y2 xe3x, y30 1y4 y1 x2ex, y40 1y5 y2 e2x, y50 1其中初值条件 y0为一个五维数组,包含了这五个方程在区间0,1左端点 0的值,并假设 N10 为区间等分数程序function rkA,x,h,y0A为字符串函数的元胞数组x为 x轴上的各点h为点距y0为初值i1;yi,y0;mlengthA;bxlengthx;while xi y13*a22*a3-2*a121*exp2*a1; 解释a1为 x,a2、a3为 y1,y2 y24*a2a3a122*a1-4*exp2*a1; y32*a2-a3-a1*exp3*a1; y4a2a12*expa1; y5a3-exp2*a1; Ay1,y2,y3,y4,y5A 1x38 char 1x41 char 1x28 char 1x21 char a3-exp2*a1 rkA,00.11,0.1,ones1,5y 1.0000 1.0000 1.0000 1.0000 1.00001.4692 1.1649 1.1312 1.1226 0.99632.1246 1.5112 1.3309 1.3031 0.99303.0680 2.1507 1.6105 1.5679 1.00784.4629 3.2638 1.9873 1.9573 1.07186.5725 5.1403 2.4884 2.5335 1.23769.8237 8.2476 3.1587 3.3940 1.593014.9117 13.3402 4.0745 4.6925 2.283722.9721 21.6384 5.3681 6.6746 3.549735.8640 35.1212 7.2699 9.7346 5.784356.6365 57.0045 10.1818 14.5095 9.6315