Download presentation
Presentation is loading. Please wait.
Published byAnnemari Hovinen Modified 5年之前
1
第九单元 第1课 实验 Matlab动画 1.洛仑兹非线性奇异方程所描述的无序运动 2.作y=sin(x)的程序动画(1)
3.实现快速fourier变换的电影动画 4.作y=sin(x)的程序动画(2) 5.作函数lim_{x->+inf}\ftac{x-sin(x)}{x+sin(x)}极限的语言的电影动画程序 6.图形 实验目的:掌握matlab两类动画程序设计方法。
2
1.洛仑兹非线性奇异方程所描述的无序运动 % 洛仑兹方程
% 洛仑兹方程 %dx/dt=-sigma(x-y);dy/dt=-xz+rx-y;dz/dt=xy-bz %li2_5_1 clear a=[-8/3 0 0; ; ]; y=[ ]'; h=0.01; p=plot3(y(1),y(2),y(3),'.','EraseMode','none','MarkerSize',5); %将擦除模式设置为none axis([ ]) hold on for i=1:4000 a(1,3)=y(2); a(3,1)=-y(2); ydot=a*y; y=y+h*ydot; set(p,'XData',y(1),'YData',y(2),'ZData',y(3)) %设定图形目标的性质 drawnow%填充未完成的图形事件 end
3
2.作y=sin(x)的程序动画(1) %li2_5_2.m clear axis([0,2*pi,-1,1]) x=0:0.01:2*pi; figure; plot(x,0) hold off hold on for j=1:30 t1=(j-1)*2*pi/30; t2=j*2*pi/30; t=t1:0.01:t2; plot(t,0,'.r') plot(t,sin(t),'.') end
4
3.实现快速fourier变换的电影动画 %li2_5_3.m clear axis equal%创建一个用于显示该电影动画的坐标轴 m=moviein(16); set(gca,'NextPlot','replacechildren') for j=1:16 plot(fft(eye(j+16))) m(:,j)=getframe; end movie(m,30)
5
4.作y=sin(x)的程序动画(2) %li2_5_4.m clear all axis([0,2*pi,-1,1]) hold off x=0:0.01:2*pi; plot(x,0,'-g','LineWidth',10) m=moviein(16); hold on for i=1:30 for j=1:i t1=(j-1)*2*pi/30; t2=j*2*pi/30; t=t1:0.02:t2; axis([0,2*pi,-1,1])%限制动画的坐标显示大小 plot(t,0,'.r') plot(t,sin(t),'.') end m(:,i)=getframe; end movie(m,30)
6
5.作函数lim_{x->+inf}\ftac{x-sin(x)}{x+sin(x)}极限的语言的电影动画程序
function x1=li2_5_5(a) %li2_5_5.m作函数 极限的 语言的电影动画程序 % a取0.1~0.01之间 hold off axis([0,70,0,1.8]) x=0.01:0.01:70; y=(x-sin(x))./(x+sin(x)); plot(x,y,'-g'); hold on plot(x,1+a,'-b'); plot(x,1-a,'-b'); m=moviein(16); for k=70:-0.1:1 if abs(((k-sin(k))/(k+sin(k)))-1)>a x1=k; break; end end
7
n2=floor(x1)+1; for j=1:n2 if j==1 t1=0
n2=floor(x1)+1; for j=1:n2 if j==1 t1=0.01; t2=1; else t1=j-1; t2=j; end t=t1:0.01:t2; axis([0,70,0,1.8]) %设定坐标轴显示尺寸 y=(t-sin(t))./(t+sin(t)); plot(t,0,'.r'); plot(t,y,'-r'); m(:,j)=getframe; end t=0:0.01:1+a; n=length(t); n1=n2*ones(1,n); plot(n1,t,'.g') m(:,n2+1)=getframe; movie(m,30)
8
6.图形
Similar presentations