% M-file for Sec2 Lec 03. % % Plots for Figure 61 of PW p1 = 1; if( p1 == 1 ) % Generate gp(t) = 1-phi^2/(1+phi^2-2pji*cos(t)) phi = 0.9; arg = [-pi:0.01:pi]; gp = (1-phi^2)./(1+phi^2-2*phi*cos(arg)); % gp,m=1+2*sum+n=1^m[(phi^2*cos(nt)] m = 4; l=length(arg); c = zeros(32,l); for n = 1:32 c(n,:) = phi^n*cos(n*arg); end % Now sum the functions to different levels gp04 = 1 + 2*sum(c([1:4],:)); h1 = figure(1); set(h1,'Position',[100 300 750 160],'PaperPositionMode','auto'); plot(arg,gp,'b',arg,gp04,'r'); axis tight; title('Approximation to (1-\phi^2)./(1+\phi^2-2\phi cos(arg)) with m=4, \phi=0.9'); print -dpng S2L03_gp04.png % Now sum the functions 8 level gp08 = 1 + 2*sum(c([1:8],:)); h2 = figure(2); set(h2,'Position',[120 280 750 160],'PaperPositionMode','auto'); plot(arg,gp,'b',arg,gp08,'r'); axis tight; title('Approximation to (1-\phi^2)./(1+\phi^2-2\phi cos(arg)) with m=8, \phi=0.9'); print -dpng S2L03_gp08.png % Now sum the functions to 16 levels gp16 = 1 + 2*sum(c([1:16],:)); h3 = figure(3); set(h3,'Position',[140 260 750 160],'PaperPositionMode','auto'); plot(arg,gp,'b',arg,gp16,'r'); axis tight; title('Approximation to (1-\phi^2)./(1+\phi^2-2\phi cos(arg)) with m=16, \phi=0.9'); print -dpng S2L03_gp16.png % Now sum the functions to 32 levels gp32 = 1 + 2*sum(c([1:32],:)); h4 = figure(4); set(h4,'Position',[160 240 750 160],'PaperPositionMode','auto'); plot(arg,gp,'b',arg,gp32,'r'); axis tight; title('Approximation to (1-\phi^2)./(1+\phi^2-2\phi cos(arg)) with m=32, \phi=0.9'); print -dpng S2L03_gp32.png end p2 = 1; if( p2 == 1 ) % Generate Gaussion pair: sig = 1; t = [-4:0.02:4]; f=t; gt1 = 1/sqrt(2*pi*sig^2)*exp(-(t.*t)/(2*sig^2)); Gf1 = exp(-2*pi*f.*f*sig^2); h1 = figure(5); set(h1,'Position',[100 300 750 160],'PaperPositionMode','auto'); plot(t,gt1,'r',f,Gf1,'k'); axis tight; title('Gaussian with transform \sigma=1'); print -dpng S2L03_gt1.png sig = 4; gt4 = 1/sqrt(2*pi*sig^2)*exp(-(t.*t)/(2*sig^2)); Gf4 = exp(-2*pi*f.*f*sig^2); h2 = figure(6); set(h2,'Position',[120 280 750 160],'PaperPositionMode','auto'); plot(t,gt4,'r',f,Gf4,'k'); axis tight; title('Gaussian with transform \sigma=4'); print -dpng S2L03_gt4.png end