Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
VLAB – Session 1
1
Digital Signal Processing
M. Ruggieri – T. Rossi
Digital Signal Processing
M. Ruggieri – T. Rossi 2
Generation of sequences
Unit impulse e unit step.Note: Although in theory we are required to define a signal in the [-∞ ,+∞] range, in Matlab we can represent only a part of a signal within a finite range as a vector with a finite number of elements.
Generation of the domain of our sequences, a vector whose values range from -10 to 20 (with a unitary step).
Generation of the values of the sequences, two vectors, one for the unit sample and one for the unit step.
‘stem’ is a function used to plot sequences (see Matlab help)
Digital Signal Processing
M. Ruggieri – T. Rossi 3
Complex exponential sequence:
Generation of sequences (cont’d)
Definition of the signal
Plot of the real and imaginary parts of the signal. ‘subplot’ is a function to create subplots inside a figure (see Matlab help)
Polar plot of the signal
Digital Signal Processing
M. Ruggieri – T. Rossi 4
Sinusoidal sequence:
Definition of the signal, the argument of ‘cos’ is in radians
What is “f”? “f” is a frequency but its unit is not Hz! It measures the cycles per sample!
Which is the period of this sequence?
What is theta?
Generation of sequences (cont’d)
Digital Signal Processing
M. Ruggieri – T. Rossi 5
Three-points moving average filter:
Random noise generation through ‘rand’ function (see Matlab help)
Is this a FIR or IIR filter?
What is the effect of this filter? This filter smoots the input signal.
A first LTI Filter Example
This filter can be used to reduce the noise of a signal.Lets define a signal and corrupt it with noise.
Signal generation
Signal corrupted by noise
Definition of the output of the filter
𝑦 𝑛 =1
3𝑥 𝑛 + 𝑥 𝑛 − 1 + 𝑥(𝑛 − 2)
Digital Signal Processing
M. Ruggieri – T. Rossi 6
Plot of filter input and oputput signals
A first LTI Filter Example (cont’d)
Consider a generic N-points moving average filter. What is the length of the filter?
What is the effect of an increase of filter lenght? --> The smoothness of the output increases! If the length of the filter is the same of the input the output is the input signal mean.
Calculation of the residual noise (after moving-average filtering)
Note: Matlab has built-in functions to define and manage LTI filters that have not been used here but will be introduced in the next examples
Digital Signal Processing
M. Ruggieri – T. Rossi 7
Consider the DT system defined by:
Definition of two input signals and their linear combination
Linearity property of a DT system
Lets check the linearity property:
The filter in matlab is defined through the coefficients of the linear constant coefficients equation
Outputs of filter for the three input signals
Filter output is calculated thorugh the ‘filter’ function (see Matlab help).
Digital Signal Processing
M. Ruggieri – T. Rossi 8
Linearity property of a DT system (cont’d)
Verification of the linearity property: if ‘d’ is equal to zero the system satisfies the property
Plot of the output signals and their difference
Note: the difference signal, ‘d’, is not exactly zero (but very close to it) due to calculation rounding and truncation effects.
Digital Signal Processing
M. Ruggieri – T. Rossi 9
Consider the DT system defined by:
Filter definition through the coefficients of the linear constant coefficients equation
LTI system impulse response
For an IIR filter it is not possible to comupte infinite samples of the inpulse response, hence Matlab function needs the number of inpulse response samples to be calculated as input.
Through the ‘impz’ function Matlab calculates the first N samples of the impulse response (see Matlab help)
Digital Signal Processing
M. Ruggieri – T. Rossi 10
Verification of filter stability property based on the sum of impulse response samples absolute values:
Recursive calculation of the sum of impulse response samples absolute values.The system impulse response samples modulus follows a decreasing trend, hence it can be supposed that if (for a certain value of ‘n’) a very low value, ε, is reached the summation converges. The value of εhas been set to 10-6
LTI system impulse response (cont’d)
Digital Signal Processing
M. Ruggieri – T. Rossi11
Calculation of linear convolution between a FIR filter impulse response and a finite-length sequence.
Matlab ‘conv’ function ca be used to coumpute linear convolution (see Matlab help).
Linear convolution computation
Sequences definition
Which is the length of the linear convolution?
Matlab ‘filter’ function ca be used to coumpute linear convolution. But we have to remember that the output length of ‘filter’ function is the same of the input signal, hence if we want the full values of the lienar convolution we have to use a zero-padding
Digital Signal Processing
M. Ruggieri – T. Rossi12
The DTFT of a sequence is a continuous, complex and periodic function. It is not possible for a calculator to compute infinite values, hence we have to identify a sampling of the frequency response domain.
Filter frequency response
Matlab ‘freqz’ function can be used to calculate system frequency response (see Matlab help)
Is this a LP, HP, BS or BP filter?
Digital Signal Processing
M. Ruggieri – T. Rossi13
Finite-length sequences definition
Convolution through DTFT
DTFT calculation for the two sequences
Convolution calculation in the discrete-time domain
Product of the two DTFTs
DTFT calculation for the DT domain convolution
Evaluate if the plot of ‘hp’ and ‘h3’ are identical
Digital Signal Processing
M. Ruggieri – T. Rossi14
Time- and frequency-shifting properties of DTFT
Test sequence
Sequence DTFT
DTFT of time-shifted sequence
Check the differences between the two spectra
DTFT properties:
Plot of modulus and phase of the two DTFTs
Digital Signal Processing
M. Ruggieri – T. Rossi15
Time- and frequency-shifting properties of DTFT
(cont’d)
Test sequence
Sequence DTFT
Modulated sequence and its DTFT
Check the differences between the two spectra
Plot of modulus and phase of the two DTFTs