当前位置:首页 > 数学应用软件作业6 用Matlab求解微分方程(组)的解析解和数值解
plot(T,Y(:,1),'+',T,Y(:,2),'*'); title('ode15s图形'); 题4: Matlab程序: (1)先建立程序timu41.m如下: y=dsolve('Dy=-y+t+1','y(0)=1','t') 截图如下: 作图:建立程序tuxing41.m如下: ezplot('t + 1/exp(t)',[0,1]) title('t + 1/exp(t)') (2)先建立M文件fun3.m,如下: function dy=fun3(t,y) dy=zeros(1,1); dy(1)=-y(1)+t+1; 再取t0=0,tf=1,建立程序tuxing42.m如下: t0=0;tf=1; [T,Y]=ode45('fun3',[0 1],[1]); plot(T,Y,'ro'); title('比较图'); t=0:0.1:1; y=t+1./exp(t); hold on plot(t,y,'b'); 四. 上机结果 题1结果为: ans = C4*exp(2*x) + C2*exp(x*(5^(1/2)/2 - 1/2)) + C3/exp(x*(5^(1/2)/2 + 1/2)) 题2结果为: x = 4*cos(t) - 2/exp(2*t) + 3*sin(t) - (2*sin(t))/exp(t) y = sin(t) - 2*cos(t) + (2*cos(t))/exp(t) 题3结果为:
共分享92篇相关文档