Matlab Training Session Vii Basic Signal Processing: Frequency Domain Analysis
Matlab Training Session Vii Basic Signal Processing: Frequency Domain Analysis
1 of 8
Often, we will associate two vectors with a signal. One vector will signify the subscript or the sequence number and the other will represent the signal value. This will be needed so that we can use the equations from signal processing without conict with MATLABs convention for numbering the elements of a vector. Usually, a signal is analysed in two domainsthe time domain and the frequency domain. The time domain signal is represented by the data values; the frequency domain signal is represented by complex number values that represent the sinusoidal frequency components that compose the signal. Some types of information are most evident from the time domain representation of the signal. For example, by looking at the time domain plot, we can usually determine if the signal is periodic, or if it is a random signal. From the time domain values, we can also easily compute additional values such as mean, variance, and power. Other types of information, such as the frequency content of a signal, are not usually evident from the time domain, and thus we may need to compute the frequency content of the signal in order to determine if it is band-limited or if it contains certain frequencies. The frequency content of a signal is also call the frequency spectrum of the signal.
the discrete Fourier transform is a periodic function, the computed values above F16 are merely the complex conjugates of the values below, no new information is given so usually only the rst half of the output of the fft is plotted.
3 of 8
One more point is the concept of leakage. If there is a frequency in the time domain signal that falls in the interval between two of the discrete frequencies used in the fft, it will be detected as a component in both frequencies, but with reduced amplitude. In MATLAB an approximation of the time domain signal can be recovered using the ifft function. Try: plot(time,ifft(F))
Filter Analysis:
The transfer function of an analog system is represented by a complex function H(s), and a transfer function of a digital system is represented by a complex function H(z). These transfer functions describe the effect of the system on an input signal, termed ltering. For a given frequency 0 the lter has a magnitude K and a phase . Then, if the input to the lter contains a sinusoid with frequency 0, the output of that component will by multiplied by K and its phase will be incremented by .
A*sin(0t + )
H(s)
K*A*sin(0t + + )
The transfer function of a lter can also be described in terms of the band of frequencies that it passes. For example, a lowpass lter will pass (unalter) frequencies below a cutoff frequency and remove (attenuate) the frequencies above. There are also highpass, bandpass, and bandstop (notch) lters. In order to determine the characteristics of a transfer function, we need to plot the corresponding magnitude and phase functions. When we have a transfer function representation of the lter (i.e. a numerator polynomial and a denominator polynomial) we can look at the magnitude characteristic with the MATLAB function freqs and freqz. Try:
4 of 8
When determining the characteristics of a digital lter using the freqz function, 3 input arguments are required. The third argument differs from freqs in the sense that instead of specifying the frequency range, you specify the number of normalized frequency values to use over the interval [0,]. Since H(z) is applied to input signals with a sampling time of T, the appropriate range of frequencies is from 0 to the Nyquist frequency, which is /T rps or 1/(2T) Hz When we assume that z is used as a function of normalized frequency, then H(z) has a corresponding range of frequencies from 0 to . The phase of a lter can be plotted using the angle function or the unwrap function. Since the phase of a complex number is a angle in radians, the angle is only unique for a 2 interval. The output of the angle function maps the phase values to values between - and , and thus can create discontinuities at points where the phase exceeds these bounds. The unwrap function removes the 2 discontinuities introduced by the angle function when used in the reference unwrap(angle(H)). b0 + b1 z + b2 z + + bn z H ( z ) = --------------------------------------------------------------------------1 2 n a0 + a1 z + a2 z + + an z yn =
1 2 n
k = N 1
N2
bk xn k
ak yn k
k=1
N3
A digital lter can also be specied using a standard difference equation, SDE, which has the general form shown above. When N1 = 0, the coefcients [bk] and [ak] are precisely the same coefcients in the transfer function H(z). If the denominator transfer function is equal to 1, the lter is an nite impulse response lter (FIR); If the denominator transfer function is not equal to 1, the lter is an innite impulse response lter (IIR). Both types of lters are commonly used in digital signal processing.
5 of 8
To design a banpass lter, Wn should be a vector containing Wp1 and Wp2. To design a highpass lter, an additional parameter high should be added as the last function parameter. To design a bandstop lter, the additional parameter stop should be added as the last function parameter.
6 of 8
Direct IIR Filter Design: MATLAB has a function for performing Yule-Walker lter designs. The command is: [B,A] = yulewalk(n,f,m) The output vectors B and A contain the coefcients of the nth order IIR lter. The vectors f and m specify the frequency-magnitude characteristics of the lter over the normalized frequency range 0 to 1, which represents the Nyquist frequency range. The frequencies in f must begin with 0 and end with 1, and be increasing. The magnitudes of m must correspond to the frequencies in f, and represent the desired lter magnitude for each f.
7 of 8
Direct FIR Filter Design: FIR lters are designed in MATLAB using the Parks-McClellan lter design algorithm that uses the Remez exchange algorithm. Recall that FIR lters require only a B vector because the denominator polynomial of H(z) is equal to 1. The command is: B = remez(n,f,m) The arguments play the same role and have the same constrains as with the yulewalk function given above. An additional rule is that the number of points in f and m must be an even number. To obtain desirable characteristics from the FIR lter, it is not unusual for the lter order to be large.
8 of 8