MATLAB MATLAB MATLAB xyz - MATLAB - MATLAB MATLAB function demo_mot1(v) %demo_mot1.m -1-
x = -pi:pi/20:pi; t=0.1; h=plot(x,cos(x),'linewidth',5); delx=v*pi/360*t; while 1 x=x+delx; set(h,'xdata',x,'ydata',cos(x)); drawnow pause(t); %if x>2*pi, x=0;; 1. X cosx plot x,y plot xdata ydaya h (handle) MATLAB plot set -2-
set(h,'xdata',x,'ydata',cos(x)); x cos(x) x=x+delx; demo_mot1 (v) 50 100 3-D (Lorenz) y(t) A y (Euler's method) %demo_mot2.m A = [ -8/3 0 0; 0-10 10; 0 28-1 ]; y = [35-10 -7]'; h = 0.01; grid on; p = plot3(y(1),y(2),y(3),'.',... 'EraseMode','none','MarkerSize',5); % Set EraseMode to none axis([0 50-25 25-25 25]) hold on -3-
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)) % Change coordinates drawnow p = plot3(y(1),y(2),y(3),'.',... 'EraseMode','none','MarkerSize',5); % Set EraseMode to none p y xyz y(1)y(2)y(3) 2(!) MATLAB MATLAB MATLAB ( -4-
%demo_mot3.m p = plot3(y(1),y(2),y(3),'square',... 'EraseMode','background','MarkerSize',10,... 'MarkerEdgeColor',[1.7.7],'MarkerFaceColor',[1.7.7]); 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 hold off; "pink eraser" ( ) (Xor Erase Mode) ( '') n = 20 s =.02 x = rand(n,1)-0.5; y = rand(n,1)-0.5; -5-
h = plot(x,y,'.'); axis([-1 1-1 1]) axis square grid off set(h,'erasemode','xor','markersize',18) while 1 drawnow x = x + s*randn(n,1); y = y + s*randn(n,1); set(h,'xdata',x,'ydata',y) demo_mot4.m %Brownian motion clf; n=20; s=0.02; x = rand(n,1)-0.5; y = rand(n,1)-0.5; h = plot(x,y,'.'); axis([-1 1-1 1]) axis square grid off set(h,'erasemode','xor','markersize',18) grid on; title('press Ctl-C to stop'); while 1 drawnow x = x + s*randn(n,1); y = y + s*randn(n,1); set(h,'xdata',x,'ydata',y) -6-
Drawnow -7-
h = image(a(:,:,:,1),'erasemode','none'); for i = 2:x set(h,'cdata',a(:,:,:,i)) drawnow X = [1 2 3 4; 5 6 7 8; 9 10 11 12]; -8-
h = image(x); colormap(colorcube(12)) xlabel x; ylabel y get(h,'xdata') ans = 1 4 get(h,'ydata') ans = 1 3 X = [1 2 3 4; 5 6 7 8; 9 10 11 12]; image(x,'xdata',[-1 2],'YData',[2 4]); colormap(colorcube(12)) xlabel x; ylabel y -9-
nframes = 50; x = rand(n,1)-0.5; y = rand(n,1)-0.5; h = plot(x,y,'.'); set(h,'markersize',18); axis([-1 1-1 1]) axis square grid off for k = 1:nframes x = x + s*randn(n,1); y = y + s*randn(n,1); set(h,'xdata',x,'ydata',y) M(k) = getframe; movie(m,30) movie(m) movie(m,n) movie(m,n,fps) movie(h,...) movie(h,m,n,fps,loc) -10-
Z = peaks; surf(z); axis tight set(gca,'nextplot','replacechildren'); % Record the movie for j = 1:20 surf(sin(2*pi*j/20)*z,z) F(j) = getframe; % Play the movie twenty times movie(f,20) M = moviein(n) M = moviein(n,h) M = moviein(n,h,rect) -11-
FFT 16 16 MATLAB axis equal M = moviein(16); set(gca,'nextplot','replacechildren') for j = 1:16 plot(fft(eye(j+16))) M(:,j) = getframe; set(gca,'nextplot','replacechildren') -12-
MATLAB ( QuickTime) 30 movie(m,30) ( uicontrols ) j axis equal M = moviein(16,gcf); set(gca,'nextplot','replacechildren') h = uicontrol('style','slider','position',... [100 10 500 20],'Min',1,'Max',16) for j = 1:16 plot(fft(eye(j+16))) set(h,'value',j) M(:,j) = getframe(gcf); clf; axes('position',[0 0 1 1]); movie(m,30) -13-