matlab习题及答案 下载本文

内容发布更新时间 : 2024/5/2 8:48:56星期一 下面是文章的全部内容请认真阅读。

>> f=inline('[-x(2)-x(3);x(1)+a*x(2);b+(x(1)-c)*x(3)]','t','x','flag','a','b','c'); >> [t,x]=ode45(f,[0,100],[0;0;0],[],0.2,0.2,5.7); >> plot3(x(:,1),x(:,2),x(:,3));grid

>> [t,x]=ode45(f,[0,100],[0;0;0],[],0.2,0.5,10); >> plot3(x(:,1),x(:,2),x(:,3));grid

第十二题 >>

f=inline(['[x(2);-x(1)-x(3)-(3*x(2))^2+(x(4))^3+6*x(5)+2*t;','x(4);x(5);-x(5)-x(2)-exp(-x(1))-t]'],'t','x');

>> [t1,x1]=ode45(f,[1,0],[2,-4,-2,7,6]'); >> [t2,x2]=ode45(f,[1,2],[2,-4,-2,7,6]');

>> t=[t1(end:-1:1);t2];x=[x1(end:-1:1,:);x2]; >> plot(t,x)

>> figure;plot(x(:,1),x(:,3))

第十三题

>> [t,x,y]=sim('yws',[0,10]);plot(t,x)

>> figure;plot(t,y)