ME 452 Fourier Series and Fourier ransform Fourier series From Joseph Fourier in 87 as a resul of his sudy on he flow of hea. If f() is almos any periodic funcion i can be wrien as an infinie sum of sines and cosines. a f ( ) = + a Cos( ) + b Sin( ) ω ω 2 = = where 2 2 = f Cos d ( ) ( ω ) and b = f Sin d ( ) ( ω ) a Find he Fourier series for he square wave shown below. Period is 2 and frequency is /(2). Figure A square wave wih a period of 2. Soluion: o find he coefficiens a and b, we need o inegrae over one period. For his problem we will ae he period from o 2. he equaion for f() is: f ( ) = + 2 he equaions for a and b can be evaluaed as: 2 a = + Cos d + Cos d = ( ) ( ) ( ) ( ) 2 even b = + Sin d + Sin d = ( ) ( ) ( ) ( ) 4 odd We can hen wrie f() as a Fourier series. f ( ) = 4 Sin( ) which can be wrien as = odd --
4 4 4 f ( ) = sin( ) + sin(3) + sin(5) + 3 5 In general a sinusoid can be wrien as f ( ) = Asin(2f) where A is he ampliude and f is he frequency in cycles per second or Herz. In our case A = and f = /(2). We can use MALAB o plo a few cycles. %PloSine.m f = /(2*pi); = -4*pi:pi/:4*pi; f = (4/pi)*sin(2*pi*f*); %fundamenal f = (4/(3*pi))*sin(2*pi*3*f*); %3rd harmonic f2 = (4/(5*pi))*sin(2*pi*5*f*); %5h harmonic f3 = (4/(7*pi))*sin(2*pi*7*f*); %7h harmonic figure();clf; plo(, f, ''); hold on; plo(, f, 'b'); plo(, f2, 'r'); plo(, f3, 'g'); axis([-pi pi -.4.4]);.5 -.5 - Our equaion f ( ) = 4 Sin( ) = odd -3-2 - 2 3 Figure 2 he fundamenal sinusoid and he firs hree odd harmonics. says ha we need o add all of hese sinusoids ogeher and if we do we will ge a square wave. -2-
%Fourier.m % his program plos erms of he Fourier series for a square wave. erms = [ 3 5 5 ]; %Vecor of number of erms in each plo figure();clf; for indx = :6 %6 plos sum = zeros(,24); %24 erms = linspace(-2*pi,2*pi,24); % goes from -2Pi o +2Pi for =:2:2*erms(indx) sum = sum + 4/(*pi)*sin(*); end subplo(3, 2, indx); plo(, sum, 'LineWidh', ); hold on; plo(, square(), ''); xlabel('ime'); ylabel(''); sile = ['Fourier Series wih ' in2sr(erms(indx)) ' erms']; ile(sile); axis([-2*pi 2*pi -.4.4]) end Fourier Series wih erms Fourier Series wih 3 erms.5 -.5 -.5 -.5 - -6-4 -2 2 4 6 ime Fourier Series wih 5 erms -6-4 -2 2 4 6 ime Fourier Series wih erms.5 -.5 -.5 -.5 - -6-4 -2 2 4 6 ime Fourier Series wih 5 erms -6-4 -2 2 4 6 ime Fourier Series wih erms.5 -.5 -.5 -.5 - -6-4 -2 2 4 6 ime -6-4 -2 2 4 6 ime Figure 3 Fourier series for a square wave for various number of erms. So a square wave can be hough of as an infinie sum of sinusoids a odd harmonics of he fundamenal and whose ampliude geomerically decreases wih frequency. -3-
Since we have come o regard a sinusoid as a "pure frequency" we say he square wave has a frequency conen consising of he odd harmonics of is fundamenal. he figure below shows a graph of he ampliudes of he sinusoids a he various frequencies for he square wave..4 Frequency plo of a square wave.2.8 gain.6.4.2 Figure 4 Frequency plo of he odd harmonic frequencies in a square wave. o ge he exponenial form of he series we use Euler s ideniy: ± jx e = Cos( x) ± jsin( x) Using his equaion we can wrie he cosine and sine in erms of he naural log base, e. jx jx e + e jx jx e e Cos( x) = Sin( x) = 2 2 j Subsiue hese equaions for cos and sin ino he Fourier series a f ( ) = + a Cos( ) + b Sin( ) ω ω 2 = = his gives he exponenial form of he Fourier series which can be wrien as: jω jω jθ 2 f ( ) = C e where C = f e d = C e = ( ) and ω = If we wrie he square wave in he exponenial forma hen, in Figure 4, he "Gain" number is C Fourier ransform 5 5 Frequency/(2*pi) he Fourier series applies o periodic funcions such as he square wave. If he funcion is no periodic he Fourier series no longer applies direcly insead we use he Fourier ransform. he exponenial form of he Fourier series is: f ( ) = jω C e = where C jω jθ = f e d = C e ( ) 2 and ω = -4-
he Fourier ransform is: F{ f ( )} jω = F( ω ) = f ( ) e d Noe ha he Fourier ransform is similar o he definiion of C in he Fourier series excep he inegral is from - o + and he variable ωo has become a coninuous variable ω. Lie he Fourier series he Fourier ransform is easier o undersand if we apply Euler's ideniy and wrie i in erms of sines and cosines. + F { f ( )} = F( ω ) = f ( ) cos( ω) d j f ( )sin( ω) d + In plain English wha we are doing is muliplying he funcion imes he cosine funcion and he sine funcion and finding he area under he resuling curve. he Fourier ransform can hus be viewed as a correlaion beween sines and cosines and a given signal. In MALAB we can do he Fourier ransform using he command ff which sands for Fas Fourier ransform. he FF is a fas algorihm for calculaing he Fourier ransform. % % %Do real ff fs = ; = /fs; fsig = ; = ::.-; %ime o. seconds x = cos(2*pi*fsig* - pi/6); %Signal a Hz x(lengh()/2:lengh()) = ; figure();clf; sem(, x, 'MarerSize', ); axis([. -.2.2]); ile('signal'); xlabel('ime in seconds'); ylabel(''); XFF = ff(x); XFF = XFF/max(abs(XFF)); figure(2);clf; L = lengh(x); = :L-; delaf = fs/l; f = *delaf; plo(f, abs(xff)); axis([ fs/2 ]); xlabel('frequency in Hz'); ylabel('gain'); ile('fourier ransform in MALAB'); -5-
Signal Fourier ransform in MALAB.8.6.4.2 -.2 -.4 -.6 -.8 - gain.9.8.7.6.5.4.3.2. Noe ha he Fourier ransform is given by: Figure 5 A sampled cosine wave and is ff F( ω ) ( ) jω = f e d When we ae he Fourier ransform of a signal we deermine wha sinusoidal frequencies ha signal conains. We refer o his as he frequency conen of he signal. Unforunaely, he Fourier series does no converges and herefore does no exis for many funcions. If however, we replace..2.3.4.5.6.7.8.9. ime in seconds j e ω by s e where s σ + jω = we ge F( s) s = f ( ) e d 5 5 2 25 3 35 4 45 5 frequency in Hz Which is he Laplace ransform of he signal. he Laplace ransform converges for many more signal since i muliplies he funcion, f() by e σ where σ is real and he exponenial forces a convergence. If we consider he jω erm as a se of purely imaginary numbers and he s = σ + jω as an arbirary complex number han can be real, imaginary, or complex, we see ha he Laplace ransform is a generalizaion of h Fourier ransform. his also means ha if we have a ransfer funcion of a sable sysem in s we can ge is frequency response funcion by subsiuing s = jω effecively changing he Laplace ransform funcion o he Fourier ransform funcion. -6-