170 likes | 441 Views
MATLAB Session 4. ES 156 Signals and Systems 2007 Harvard SEAS. Prepared by Jiajun Gu. OUTLINE. Fourier series of exponential signals Fourier series of a continuous-time rectangular signal Sinc function. Fourier series of exponential signals. Fourier series of Fourier series of .
E N D
MATLAB Session 4 ES 156 Signals and Systems 2007 Harvard SEAS Prepared by Jiajun Gu
OUTLINE • Fourier series of exponential signals • Fourier series of a continuous-time rectangular signal • Sinc function
Fourier series of exponential signals • Fourier series of • Fourier series of
Fourier series of exponential signals II • Fourier series of • What is Fourier series of • Discrete cases?
OUTLINE • Fourier series of exponential signals • Fourier series of a continuous-time rectangular signal • sinc function
Fourier series of a continuous-time rectangular signal II (Example 3.5)
Plot the series: FS generation function function ak=series_term(k,T1,T) % to compute Fourier series a_k % T is the period, 2*T1 is the width of the rectangular pulses % k is the input (integer). ak is the output % which is the k-th term of the Fourier series omega0=2*pi/T; if k==0 ak=2*T1/T; else ak=sin(k*2*pi/T*T1)/(k*pi); end
Plot the series: scale k-scripts Case1: T1=1, T=20; Case2: T1=1, T=10; for k=-30:30 a(k+30+1)=series_term(k,1,20); b(k+30+1)=series_term(k,1,10); end figure;subplot(2,1,1) set(gca,'fontsize',14); stem(-30:30,a,'.'); xlabel('k');ylabel('a_k') subplot(2,1,2) set(gca,'fontsize',14); stem(-30:30,b,'.'); xlabel('k');ylabel('b_k')
Plot the series: scale -Scripts figure;subplot(2,1,1) set(gca,'fontsize',14); stem((-30:30)*2*pi/20,a,'.'); xlim([-6*pi,6*pi]) % x-axis from –6pi to 6pi xlabel('k');ylabel('a_k') subplot(2,1,2) set(gca,'fontsize',14); stem((-30:30)*2*pi/10,b,'.'); xlim([-6*pi,6*pi]) % x-axis from -6pi to 6pi xlabel('k');ylabel('b_k')
OUTLINE • Fourier series of exponential signals • Fourier series of a continuous-time rectangular signal • sinc function
Definition of sinc() function • MATLAB has a built-in function sinc() • Why do we want to use sinc()? • Don’t need to write your own code. • It can take vectors as input.
Using sinc() to calculate FS T=10; k=-30:30; c=2/20*sinc(2*1/T.*k); figure;set(gca,'fontsize',14); stem(k*2*pi/T,c,'.'); xlim([-6*pi,6*pi]) xlabel('k\omega_0'); title('T_1=1,T=10')
Practice problems • Find the expression of the Fourier Series of the following signals. Plot the series. • MATLAB question in Homework 4