Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 4 The Frequency Domain of Signals and Systems.

Similar presentations


Presentation on theme: "Chapter 4 The Frequency Domain of Signals and Systems."— Presentation transcript:

1 Chapter 4 The Frequency Domain of Signals and Systems

2 Objectives Define the Fourier transform and explain some of its important properties. Define the discrete-time Fourier transform (DTFT) and demonstrate that it gives its maximum response at the digital frequencies contained in a discrete time-domain signal. Prove the three key properties of the DTFT: linearity, periodicity, and time-delay. Demonstrate the replication of the frequency content of a signal at integer multiples of the sampling frequency Demonstrate the concept of signal windowing in spectral analysis and show how different windows affect the resolution and side-lobe amplitudes of the DTFT. Explain the limitations of the DTFT and the “uncertainty principle” in spectral analysis. Define signal power and energy and demonstrate their methods of calculation in the time domain and frequency domain. Show how to simulate signals with random noise and demonstrate the spectral properties of Gaussian noise power in discrete-time signals. Derive the frequency response of a general linear time-invariant DSP system and show that the frequency response is the value of the z-domain transfer function on the unit circle in the complex plane.

3 Fourier’s Theorem Fourier’s theorem states that any continuous periodic signal can be represented by an infinite sum of harmonically related sinusoids. The coefficients (a,b,c) represent the frequency content of the signal at discrete frequencies.

4 The Fourier Coefficients of a Square Pulse Train

5

6 Computational Analysis of a Square Pulse Train (Custom M-file “pulse_train”) >> w=1; %Set the pulse width in ms >> fmax=3500; %Set the maximum harmonic frequency >> R1=4; %Set the period-to-width ratio for each case >> R2=8; >> R3=32; >> [c1,f1]=pulse_train(fmax,w,R1); %Use the M-file to compute the Fourier coefficients >> [c2,f2]=pulse_train(fmax,w,R2); % Case 2 >> [c3,f3]=pulse_train(fmax,w,R3); % Case 3 >> subplot(3,1,1),stem(f1,c1),title('Period to Width Ratio = 4'); >> subplot(3,1,2),stem(f2,c2),title('Period to Width Ratio = 8'); >> subplot(3,1,3),stem(f3,c3),title('Period to Width Ratio = 32'); >> xlabel('Harmonic Frequency - Hz') As the period-to-width ratio increases the frequency “density” of the coefficients increases. In the limit, the coefficients become a continuous function of frequency.

7 Fourier Transform The pulse train analysis suggests that for a general non-periodic signal, a continuous function of frequency represents the “frequency content” of the continuous signal. Definition of the Fourier transform:

8 The Discrete-Time Fourier Transform (DTFT) The DTFT is the Fourier transform for discrete-time signals The DTFT requires a finite causal signal for a practical calculation. Therefore, the result depends on signal length, N The DTFT is a continuous complex function of Ω Calculation of the DTFT requires N terms for a discrete Ω. Thus, practical calculations require computer assistance. Efficient computation of the DTFT is an important problem in DSP (e.g., the FFT or “Fast Fourier Transform”)

9 Example Calculation Calculate the DTFT for the signal x[n] = [1,-1,1,-1] at the digital frequencies of π and π/2. For Ω = π: For Ω = π/2

10 Example Calculation: A Short Sinusoid at 3 Frequencies >> n=0:7; >> omega1=pi/2; >> x=cos(omega1*n); >> stem(n,x), title('8 Samples of a Sinusoid of Frequency pi/2') >> xlabel('Index, n') >> omega=[0,pi/2,pi]; % Our three values of Ω >> X=[0,0,0]; % We initialize the vector for X >> for k=1:3 % For each value of omega >> for m=1:8 % For each value of the signal % Compute the DTFT summation for the kth value of Ω >> X(k)=X(k)+x(m)*exp(-j*omega(k)*(m-1)); >> end >> figure,plot(omega/pi,abs(X)) >> title('Three Points of the DTFT') >> ylabel('Magnitude of the DTFT') >> xlabel('Digital Frequency in Units of Pi')

11 Example Calculation: A Short Sinusoid at 3 Frequencies

12 Example Calculation: A Short Sinusoid at 512 Frequencies >> dtft_demo(x,0,pi,512); % Custom M-file

13 Example Calculation: A Long Sinusoid at 512 Frequencies >> n=0:99; % create a signal with 100 samples >> omega1=pi/2; >> x=cos(omega1*n); >> dtft_demo(x,0,pi,512);title('DTFT of a Sinusoid, Omega = pi/2, N = 100')

14 Properties of the DTFT Linearity Suppose y[n] = x 1 [n] + x 2 [n] The DTFT of a linear combination of signals is the same linear combination of the DTFT’s of the individual signals.

15 Properties of the DTFT Periodicity The DTFT is periodic in the Ω frequency domain with period 2π

16 Properties of the DTFT Time-Delay Suppose the DTFT of x[n] is X(Ω) and the DTFT of x[n-k] is X k (Ω) The DTFT of a signal delayed by k steps is e -jkΩ times the DTFT of the un-delayed signal

17 Replication of Spectral Content in the Frequency Domain (Periodicity of the DTFT) >> [asig,tt]=analog([50,120],[1,0.5],500,32000); >> d1000=sample(tt,asig,1000); >> d2000=sample(tt,asig,2000); >> dtft_demof(d1000,-500,500,512,1000); >> figure,subplot(2,1,1), dtft_demof(d1000,0,8000,16*512,1000); title('Fs = 1000 Hz') >> subplot(2,1,2), dtft_demof(d2000,0,8000,16*512,2000); title('Fs = 2000 Hz') Replication at integer multiples of the sampling frequency

18 Effects of Signal Length and Windowing Frequency Resolution >> N1=0:9; >> N2=0:19; >> N3=0:39; >> omega=pi/2; >> x1=cos(omega*N1); >> x2=cos(omega*N2); >> x3=cos(omega*N3); >> [X1,f]=dtft_demo(x1,0,pi,512); >> [X2,f]=dtft_demo(x2,0,pi,512); >> [X3,f]=dtft_demo(x3,0,pi,512); >> subplot(3,1,1),plot(f/pi,(abs(X1)/max(abs(X1)))),title('DTFT - N=10') >> subplot(3,1,2),plot(f/pi,(abs(X2)/max(abs(X2)))),title('DTFT - N=20') >> subplot(3,1,3),plot(f/pi,(abs(X3)/max(abs(X3)))),title('DTFT - N=40') >> xlabel('X Axis - Frequency in Units of Pi') Each doubling of the signal length reduces the main lobe width by half

19 Effects of Signal Length and Windowing Gibbs Phenomenon In all cases, the rectangular window (abrupt truncation of the signal) results in side lobes (Gibbs phenomenon)

20 Effects of Signal Length and Windowing Tapering Window: The Time Domain >> x=analog(100,1,100,4000); % 100 Hz sinusoid, 100 ms long, Fs=4kHz >> xw=x.*hamming(length(x))'; % The Hamming window is given by “hamming” >> subplot(3,1,1),plot(x),title('Rectangular Windowed Sinusoid, N=401') >> subplot(3,1,2),plot(hamming(length(x))),title('Hamming Window, N=401') >> subplot(3,1,3),plot(xw),title('Hamming Windowed Sinusoid, N=401') >> xlabel('X Axis - Sample Index') The window function (Hamming) tapers the abrupt truncation of the signal but preserves its frequency characteristics

21 Effects of Signal Length and Windowing Tapering Window: The Frequency Domain >> N=0:39; >> omega=pi/2; >> x=cos(omega*N); >> xw=x.*hamming(length(x))'; >> [X,f]=dtft_demo(x,0,pi,512); >> [XW,f]=dtft_demo(xw,0,pi,512); >> subplot(2,1,1),plot(f/pi,abs(X)/max(abs(X))); >> title('DTFT of Rectangular Windowed Signal, N=40'); >> subplot(2,1,2),plot(f/pi,abs(XW)/max(abs(XW))); >> title('DTFT of Hamming Windowed Signal, N=40'); >> xlabel('X Axis - Frequency in Units of Pi') The Hamming window suppresses the side lobes but degrades the resolution of the main lobe

22 Effects of Signal Length and Windowing Hamming and Blackman Tapering Windows >> xb=x.*blackman(length(x))'; >> [XB,f]=dtft_demo(xb,0,pi,512); >> subplot(2,1,1),plot(f/pi,20*log10(abs(XW)/max(abs(XW)))) >> title('Hamming Window') >> axis([0,1,-100,0]) >> subplot(2,1,2),plot(f/pi,20*log10(abs(XB)/max(abs(XB)))) >> title('Blackman Window') 1.The Blackman window suppresses side lobes further, but… 2.The Blackman window degrades resolution to a greater extent, r = 2.6

23 Effects of Signal Length and Windowing Comparison of Windows >> subplot(3,1,1),plot(f/pi,20*log10(abs(X)/max(abs(X)))) >> axis([0,1,-100,0]) >> subplot(3,1,2),plot(f/pi,20*log10(abs(XW)/max(abs(XW)))) >> axis([0,1,-100,0]) >> subplot(3,1,3),plot(f/pi,20*log10(abs(XB)/max(abs(XB)))) Rectangular Window Hamming Window Blackman Window

24 Spectral Analysis Problem: What is the minimum number of samples required to resolve the spectral components of the signal s(t)? Assume a sampling frequency of 10 kHz. The spectral components are separated by 500 Hz and the 2500 Hz component is -50 dB below the other two components. Pick 300 Hz as the desired resolution. A Blackman window would be required to suppress the side lobes more than 50 dB

25 Spectral Analysis The Importance of Correct Windowing >> x=analog([2000 2500 3000],[1.0032 1],17.3,10000); >> xh=x.*hamming(length(x))'; % Window the signal with a Hamming window >> xb=x.*blackman(length(x))'; % Window the signal with a Blackman window >> [Xh,f]=dtft_demof(xh,0,5000,512,10000); % DTFT of the Hamming signal >> [Xb,f]=dtft_demof(xb,0,5000,512,10000); % DTFT of the Blackman signal >> subplot(2,1,1),plot(f,20*log10(abs(Xh)/max(abs(Xh)))), axis([0 5000 -80 0]) >> title('DTFT - Hamming Window') >> subplot(2,1,2),plot(f,20*log10(abs(Xb)/max(abs(Xb)))), axis([0 5000 -80 0]) >> title('DTFT - Blackman Window') >> xlabel('Hz') The Hamming window does not suppress the side lobes sufficiently to resolve the weak component at the correct relative amplitude (-50 dB) The signal length is 173

26 The Discrete Fourier Transform (DFT) The DFT is a discrete transform X[k] of a digital signal rather than a continuous transform like X(Ω) The length of the DFT is equal to the length of the signal The DFT is defined always over the interval Ω = [0,2π] The DFT turns out to be a sample of the DTFT of x[n] over the interval [0,2π].

27 The Discrete Fourier Transform (DFT) >> n1=0:10; >> n2=0:40; >> f=pi/4; >> y1=cos(f*n1); >> y2=cos(f*n2); >> subplot(2,1,1),stem(n1,y1);title('Short Signal, y1'),xlabel('Sample') >> subplot(2,1,2),stem(n2,y2);title('Long Signal, y2'),xlabel('Sample') >> [X1,omega1]=dft_demo(y1); >> [X2,omega2]=dft_demo(y2); >> subplot(2,1,1),stem(omega1/pi,abs(X1));title('DFT of y1') >> subplot(2,1,2),stem(omega2/pi,abs(X2));title('DFT of y2') >> xlabel('X axis: Digital Frequency in of pi')

28 The Discrete Fourier Transform (DFT) >> [X1_dtft,omega_dtft]=dtft_demo(y1,0,2*pi,512); >> plot(omega_dtft/pi,abs(X1_dtft)) >> hold >> stem(omega1/pi,abs(X1), 'k') >> legend('DTFT of x1','DFT of x1') >> title('Comparison of DTFT and DFT for Signal x1') >> hold off The DFT of a signal is a sample of the DTFT in the interval [0,2π]

29 Inverse Transforms Inverse DTFT Inverse DFT

30 Energy and Power in Signals Analog signals physically transport energy between two points to do useful work (for example, from an amplifier to a speaker). Digital signals carry information but not physical energy (digital signals are simply numbers that represent analog signals). We seek something that mathematically represents energy and power (rate of change of energy) for digital signals that is computable from their numerical values.

31 Power and Energy in Analog Signals For a sinusoidal voltage with amplitude A, the power dissipated in the impedance is That is, the power is proportional to mean square of the voltage. The energy consumed is the power X time,

32 Power and Energy in Digital Signals By analogy with an analog signal, we can define the power in a digital signal to be the mean square of the signal values. Since the number of samples, N, defines a time window (t = NT s ), we can define the energy in a digital signal to be:

33 Parseval’s Theorem Physical signals must obey the conservation of energy. A signal in the time domain must have the same power as the signal in the frequency domain. Digital signals must also have the same power in the two domains. Using the inverse DTFT, it can be shown that: In the above equation, the LHS is the time domain, while the RHS is the frequency domain. This result is called Parseval’s Theorem

34 Energy Conservation in Signals Parseval’s Theorem states that a digital signal must have the same power in both the time (sample) domain and the frequency domain Energy conservation also implies that digital signal power cannot depend on the sampling frequency (f s )

35 Example Power Calculations Compute the power in the signal: The power in the analog signal is 2 2 /2+1 2 /2 +.5 2 /2=2.625 Compute the power in the digital signal: –At two different sampling frequencies (1 kHz, 2kHz) –In the time domain (mean square of the signal values) –In the frequency domain (integration of the DTFT using the custom M-file sig_power)

36 Example Power Calculations % Construct a pseudo-analog signal and sample at two different F s : >> [s,t]=analog([100,200,300],[2,1,.5],1000,50000); >> d1000=sample(t,s,1000); >> d2000=sample(t,s,2000); % Compute the time domain power: >> [mean(d1000.^2),mean(d2000.^2)] ans = 2.6224 2.6237 (Total Power does not depend on F s ) % Compute the frequency domain power: >> [sig_power(d1000),sig_power(d2000)] ans = 2.6224 2.6237 (Frequency domain power = time domain power)

37 Gaussian Noise Random electrical noise from the environment and thermal noise from components can contaminate analog voltage signals. The noise usually has a “normal” or “Gaussian” statistical distribution In MATLAB, Gaussian noise can be simulated with the “randn” random number generator.

38 Normal Distribution of “randn” % Create a randn vector with 1000 values: >> N=1:1000; >> rn=randn(size(N)); % Compute a histogram of randn values with 11 bins from -3 to 3: >> xr=-3:6/10:3; >> M=hist(rn,xr); % Plot a “normalized”(area = 1) histogram of the randn values: >> bar(xr,M/(.6*sum(M))) % Compute the normal pdf of mean 0 and variance 1 from -3 to 3: >> xn=-3:.01:3; >> y=pdf('normal',xn,0,1); % Plot the pdf on the histogram plot: >> hold >> plot(xn,y,'r','LineWidth',2) >> hold off >> legend('Normalized histogram of randn values','The normal distribution')

39 Normal Distribution of “randn”

40 Noise Signals >> N1=1:1000; >> N2=1:2000; >> t1=N1; % Define each signal to be 1000 milliseconds long >> t2=N2/2; >> n1=randn(size(N1)); % n1 is 1000 samples, 1 ms per sample >> n2=randn(size(N2)); % n2 is 2000 samples, 0.5 ms per sample >> subplot(2,1,1),plot(t1,n1),title('Gaussian Noise Signal Sampled at 1 kHz') >> axis([0 1000 -4 4]) >> subplot(2,1,2),plot(t2,n2),title('Gaussian Noise Signal Sampled at 2 kHz') >> axis([0 1000 -4 4]) >> xlabel('X axis - time in milliseconds') The amplitude of the randn noise signal is, with high probability, between -3 and 3 because it has mean zero and standard deviation 1

41 Frequency Domain of Gaussian Noise >> [X1,f1]=dtft_demof(n1,0,1000,1024,1000); >> [X2,f2]=dtft_demof(n2,0,2000,1024,2000); >> subplot(2,1,1),plot(f1,abs(X1)),title('DTFT of n1, Fs = 1 kHz') >> subplot(2,1,2),plot(f2,abs(X2)),title('DTFT of n2, Fs = 2 kHz') >> xlabel('X Axis - Frequency in Hz') For both sampling frequencies, the noise power is uniformly distributed in the frequency domain

42 Noise Power Density in the Frequency Domain Noise power density is inversely proportional to the sampling frequency

43 Power Density and Sampling Frequency >> p1=(abs(X1)).^2/(1000*length(n1)); % The power density of signal n1 >> p2=(abs(X2)).^2/(2000*length(n2)); % The power density of signal n2 >> subplot(2,1,1),plot(f1,p1),title('Power Density of n1, Fs = 1 kHz') >> axis([0 1000 0 6e-3]) >> subplot(2,1,2),plot(f2,p2),title('Power Density of n2, Fs = 2 kHz') >> axis([0 2000 0 6e-3]) >> xlabel('X Axis - Frequency in Hz') >> mean(p2) % The average of the power density of signal n2 >> mean(p1) % The average of the power density of signal n1 ans = 5.0565e-004 ans = 8.9208e-004

44 Frequency Response The frequency response of a general LTI system can be derived by taking the DTFT of the difference equation, using the linearity and time-delay properties. H(Ω) is the value of the transfer function H(z) on the unit circle z = e jΩ

45 Filter Shape and Symmetry >> omega=-pi:2*pi/100:pi; % a vector of 100 values from –pi to pi >> z=exp(j*omega); % the complex number on the unit circle from –pi to pi >> H=(.0959-0.1917*z.^-2+0.0959*z.^-4)./(1+0.9539*z.^-2+0.3373*z.^-4); >> plot(omega/pi,abs(H)) >> title('Example of Filter Shape and Symmetry') >> xlabel('Digital Frequency in Units of Pi') >> ylabel('Magnitude of the Filter Frequency Response') |H(Ω)| is symmetric about the real axis (Ω = 0)

46 Filter Shape and Symmetry >> plot(omega/pi,angle(H)) >> title('Filter Phase Angle and Symmetry') >> xlabel('Digital Frequency in Units of Pi') >> ylabel('Phase Angle in Radians') The phase angle is anti- symmetric about the real axis

47 Summary The frequency domain of a discrete-time signal is computed from its discrete-time Fourier transform (DTFT). The important properties of the DTFT are its linearity, periodicity, and its time delay property. Use of the DTFT for spectral analysis requires consideration of signal length (resolution) and window functions (suppression of the Gibbs phenomenon) Conservation of energy (Parseval’s Theorem) requires signal power to be the same in the time-domain and frequency domain Total signal power cannot depend on the sampling frequency Signal power density is inversely proportional to the sampling frequency. The frequency response of a linear-time invariant DSP system is the value of its transfer function on the unit circle in the complex plane, provided we interpret the angle in the complex plane as the digital frequency, Ω.


Download ppt "Chapter 4 The Frequency Domain of Signals and Systems."

Similar presentations


Ads by Google