% This program will draw the graphs of the functions in Table 3.1 % found on page 85 of the EE 437 book % September 14, 2006

close all;

t = -5:.0001:5; % Time Block w = -10:.0002:10; % Frequency Block a = 1; % Arbitrary Parameter = 1

UnitStep = [zeros(1,length(t)/2) ones(1,(length(t)/2) +1)];

figure(1) subplot(3,2,1) plot(t,UnitStep.*exp(-a*t),'*-') title('e-1^tu(t)')

subplot(3,2,3) plot(t,(1-UnitStep).*exp(a*t),'*-') title('e1tu(-t)')

subplot(3,2,5) plot(t,exp(-a*abs(t)),'-*') title('e-1|t^|')

subplot(6,2,2) plot(w,real(1./(a+j*w)),'*-'); title('Real Spectrum') subplot(6,2,4) plot(w,imag(1./(a+j*w)),'*-') title('Imaginary Spectrum')

subplot(6,2,6); plot(w,real(1./(a-j*w)),'*-') title('Real Spectrum') subplot(6,2,8) plot(w,imag(1./(a-j*w)),'*-') title('Imaginary Spectrum')

subplot(6,2,10) plot(w,real(2./(a.2+w.2)),'*-') title('Real Spectrum') subplot(6,2,12) plot(w,imag(2./(a.2+w.2)),'*-') title('Imaginary Spectrum')

figure(2) subplot(3,2,1) plot(t,t.*UnitStep.*exp(-a*t),'-*') title('te-1^tu(t)')

subplot(3,2,3) plot(t,t.^2.*UnitStep.*exp(-a*t),'-*') title('t2e-1tu(t)')

subplot(3,2,5) plot(t,[zeros(1,length(t)/2),1,zeros(1,length(t)/2)],'-*') title('dirac(t)')

subplot(6,2,2) plot(w,real(1./(a+j*w).^2),'*-') title('Real Spectrum') subplot(6,2,4) plot(w,imag(1./(a+j*w).^2),'*-') title('Imaginary Spectrum')

subplot(6,2,6) plot(w,real(2./(a+j*w).^3),'*-') title('Real Spectrum') subplot(6,2,8) plot(w,imag(2./(a+j*w).^3),'*-') title('Imaginary Spectrum')

subplot(6,2,10) plot(w,ones(1,length(w)),'*-') title('Real Spectrum') subplot(6,2,12); plot(w,zeros(1,length(w)),'*-') title('Imaginary Spectrum')

figure(3) subplot(3,2,1) plot(t,ones(1,length(t)),'*-') title('1')

subplot(3,2,3) hold all; plot(t,exp(j*1*t),'*-') plot(t,imag(exp(j*1*t)),'-') title('e-j1t')

subplot(3,2,5) plot(t,cos(t),'-*') title('cos(1t)')

subplot(6,2,2) plot(w,[zeros(1,50000),2*pi,zeros(1,50000)] ,'*-') title('Real Spectrum') subplot(6,2,4) plot(w,zeros(1,length(w)),'*-') title('Imaginary Spectrum')

subplot(6,2,6) plot(w,[zeros(1,55000),2*pi,zeros(1,45000)] ,'*-') title('Real Spectrum') subplot(6,2,8) plot(w,zeros(1,length(w)),'*-') title('Imaginary Spectrum')

subplot(6,2,10) plot(w,[zeros(1,45000),pi,zeros(1,10000-1),pi,zeros(1,45000)] ,'*-') title('Real Spectrum') subplot(6,2,12) plot(w,zeros(1,length(w)),'*-') title('Imaginary Spectrum')

figure(4) subplot(3,2,1) plot(t,sin(t),'-*') title('sin(1t)')

subplot(3,2,3) plot(t,[zeros(1,50000),ones(1,50001)],'-*') title('u(t)')

subplot(3,2,5) plot(t,[-ones(1,50000),ones(1,50001)],'-*') title('sgn(t)')

subplot(6,2,2) plot(w,zeros(1,length(w)),'*-') title('Real Spectrum') subplot(6,2,4) plot(w,[zeros(1,45000),pi,zeros(1,10000-1),-pi,zeros(1,45000)] ,'*-') title('Imaginary Spectrum')

S = 1./(j.*w); S(50000)=S(50000)+pi; subplot(6,2,6) plot(w,S,'*-') axis([-10 10 -5 5]); title('Real Spectrum') subplot(6,2,8) plot(w,imag(S),'*-') axis([-10 10 -5 5]); title('Imaginary Spectrum')

subplot(6,2,10) plot(w,2./(j.*w),'*-') axis([-10 10 -5 5]); title('Real Spectrum') subplot(6,2,12) plot(w,imag(2./(j.*w)),'*-') axis([-10 10 -5 5]); title('Imaginary Spectrum')

figure(5) subplot(2,2,1) plot(t,[zeros(1,45000), ones(1,10001), zeros(1,45000)],'-*') axis([-2 2 -1 1]); title('rect(t/1)')

Triangle1 = [zeros(1,45000),1+2.*t(45001:50000)]; Triangle2 = [1-2.*t(50001:55000),zeros(1,45000+1)]; Triangle3 = [Triangle1,Triangle2]; subplot(2,2,3) plot(t,Triangle3,'-*') axis([-2 2 -1 1]); title('tri(t/1)')

w2 = -50:.001:50; subplot(4,2,2) plot(w2,sin(w2/2)./(w2/2),'*-') title('Real Spectrum') subplot(4,2,4) plot(w2,zeros(1,length(w2)),'*-') title('Imaginary Spectrum')

subplot(4,2,6) plot(w2,(1/2)*((sin(w2/4)./(w2/4))).^2,'*-') axis([-50 50 -.5 .5]); title('Real Spectrum') subplot(4,2,8) plot(w2,zeros(1,length(w2)),'*-'); axis([-50 50 -.5 .5]); title('Imaginary Spectrum')

EE437 s S Table Code (last modified 2007-02-22 18:30:29)