Howto Animate Graphs in Matlab
A Simple Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Animation with Sub-figures
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | clear all; close all; clc; f0 = 10; N = 1024; t = linspace(0,10,N); NFFT = 2^nextpow2(N); fs = 1/(t(2)-t(1)); aa = 0.001:0.002:0.1; L = length(aa); axis tight; set(gca,'nextplot','replacechildren'); for kk = 1:L a = aa(kk); ff = f0 - a*t; y = cos(2*pi*ff.*t); subplot(221); plot(t,ff); hline(f0); ylim([5,12]); text(2,9.2,['\alpha=',num2str(a)]) subplot(222); plot(t,y,'r-'); subplot(212); periodogram(y,[],NFFT,fs); vline(f0); ylim([-50,2]) F(kk) = getframe(gcf); end h2 = figure; movie(h2,F,10) |

