450 likes | 594 Views
DCSP-12. Jianfeng Feng Jianfeng.feng@warwick.ac.uk http://www.dcs.warwick.ac.uk/~feng/dsp.html. For example, if a sequence is a sinusoid x(n)=cos( w 0 n) of infinite length, its DTFT yields two `delta' functions, X( w )= p d ( w - w 0 )+ p d ( w + w 0 )
E N D
DCSP-12 Jianfeng Feng Jianfeng.feng@warwick.ac.uk http://www.dcs.warwick.ac.uk/~feng/dsp.html
For example, if a sequence is a sinusoid x(n)=cos(w0 n) of infinite length, its DTFT yields two `delta' functions, X(w)= p d (w - w0)+ p d (w +w0) as in Fig. below where we assume all frequencies w and w0 to be within the intervals [- p , p ). Here d (x) is the Dirac delta function (not confused with the unit impulse defined before)
This shows that the DTFT gives perfect frequency localization as an exact concentration of energy at - w0 andw0 provided
This shows that the DTFT gives perfect frequency localization as an exact concentration of energy at - w0 andw0 provided (a) the sequence lasts from -infinity to infinity and we have an infinite amount of memory to actually collect all the data points, and
This shows that the DTFT gives perfect frequency localization as an exact concentration of energy at - w0 andw0 provided (a) the sequence lasts from -infinity to infinity and we have an infinite amount of memory to actually collect all the data points, and (b) we compute X( w ) for all possible frequencies w in the interval [- p, p ), again requiring an infinite amount of memory and an infinite computational time.
In practice, we do not have infinite memory, we do not have infinite time, and also any signal we want to analyze does not have infinite duration.
In practice, we do not have infinite memory, we do not have infinite time, and also any signal we want to analyze does not have infinite duration. In addition, the spectrum of the signal changes with time, just as music is composed of different notes that change with time.
In practice, we do not have infinite memory, we do not have infinite time, and also any signal we want to analyze does not have infinite duration. In addition, the spectrum of the signal changes with time, just as music is composed of different notes that change with time. Consequently, the DTFT generally is not computable unless we have an analytical expression for the signal we analyze, in which case we can compute it symbolically.
But most of the time this is not the case, especially when we want to determine the frequency spectrum of a signal measured from an experiment.
But most of the time this is not the case, especially when we want to determine the frequency spectrum of a signal measured from an experiment. In this situation, we do not have an analytical expression for the signal, and we need to develop an algorithm that can be computed numerically in a finite number of steps, such as the discrete Fourier transform (DFT).
clear all • close all • N=10; %sampling rate N Hz • T=20; % time • d1=1; % first period • d2=0 % second period • for i=1:T*N • t(i)=i/N; • x(i)=cos(d1*2*pi*i/N)+cos(d2*2*pi*i/N); • end • figure(1) • plot(t,x) • figure(2) • plot(t*N/(T),abs(fft(x))) • xlim([0 N/2]); • xlabel('Hz')
clear all • close all • sampling_rate=100;%Hz • omega=20; %signal frequecy Hz • N=10000; %total number of samples • for i=1:N • x_sound(i)=cos(2*pi*omega*i/sampling_rate); %signal • x(i)=cos(2*pi*omega*i/sampling_rate)+2*randn(1,1); %signal+noise • axis(i)=sampling_rate*i/N; % for psd • time(i)=i/sampling_rate; % for time trace • end • subplot(1,2,1) • plot(time,x); %signal + noise, time trace • subplot(1,2,2) • plot(axis,abs(fft(x)),'r'); % magnitude of signal • sound(x_sound); %true signal sound
The relationship between DFT and DTFT w = 2 p k /N
In spite of their similarities, the DFT and DTFT are two quite different operations. Whereas the DFT is a numerical operation, which computers a finite number of coefficients X(0), … ,X(N-1) from a finite set of data x(0), … ,x(N-1),
the DTFT is not computable numerically because it yields a continuous function, X(w), based on an infinite sequence x(n). In this section we address the problem of estimating X(w)=DTFT{x(n)} based on the DFT of a sample of finite length N.
Now the question is, will XN converges to X as N tends to infinity for each value of the frequency variable w ?. If the answer is positive, the approximation makes sense and we can say that we can estimate the frequency spectrum of the whole signal based on a set of samples. The more data(i.e. the larger N is), the better the approximation.
The answer Three cases • absolutely summable • finite energy • general case
Absolutely summable signals. These signals are such that S |x(n)| < infinity For these signals the DTFT always exists, is finite, and converges for every w as
These are the best-behaved sequences, in terms of convergence. This means that for every w, we can approximated X ( w ) infinitely closely by the finite sequence XN ( w ), with N sufficiently large. Typical examples in this class are signals decaying as 1/n2 for which |x(n)| < C/ n2, for n sufficiently large. In particular, signals decaying exponentially fast.
Gibbs phenomena: cause a lot troubles in practice applications
Third case: Example: cos (omega_0 n)
DFT for spectral estimation One of the uses of the DFT is to estimate the frequency spectrum of a signal. The Fourier transform of a function produces a spectrum from which the original function can be reconstructed by an inverse transform. So it is reversible. (signal processing: transforms, demo)
In order to do that, it preserves not only the magnitude of each frequency component, but also its phase. This information can be represented as a 2-dimensional vector or a complex number, or as magnitude and phase (polar coordinates). In graphical representations, often only the magnitude (or squared magnitude) component is shown. This is also referred to as a power spectrum .
In particular, given a continuous time signal x(t), the goal is to determine its frequency components by taking a finite set of samples as a vector, (x(0), x(1),…, x(N-1)), and computing its DFT as in the previous section.
The fact that we window the signal x(n) (i.e. we take a finite set of data) will have an effect on the frequency spectrum we compute, and we have to be aware of that when we interpret the results of the DFT. This can be seen by defining a window sequence
and the DTFT of the windowed signal Now notice that we can relate the right-hand side of the preceding expression to the DFT of the finite sequence x(0), … ,x(N-1)
To see the effect of the windowing operation on the frequency spectrum, let us examine the case when the signal x(n) is a complex exponential, such as x(n) = exp( j w0 n)
Two effects of DFT • Lose of resolution • Leakage of energy from mainlobe to sidelobes
As we have seen, the DFT is the basis of a number of applications, and is one of the most important tools in digital signal processing. The problem with this algorithm is that a brute-force implementation would hardly be feasible in real time, even for a data set of modest length.
Fortunately, the DFT can be computed in a very efficient way, exploiting the very structure of the algorithm we have presented by using the fast Fourier transform (FFT), which is an efficient way of computing he DFT. It is know that for a data set of length N, the complexity of the FFT grows as N log N, the complexity of the DFT computed by brute force grow as N2. FFT is widely used in many applications.
Spectrogram • A spectrogram is an image that shows how the power spectrum of a signal varies with time.
Frequency Time
Sampling and reconstruction The question we consider here is under what conditions we can completely reconstruct the original signal x(t) from its discretely sampled signal x(n).