Signals and Systems - Mock Exam 3
Questa pagina non ha ancora la versione ripasso: qui sotto c'è il testo completo.
In questa pagina 7
Mock exam built on the model of the written exams of the equivalent course in Italian (Segnali e Sistemi, Information Engineering, UniPD, exams of 22 January 2025, 10 February 2025 and 16 February 2026). It is a simulation, not an exam given by the course. It has the same structure as the model exams: three exercises of 7 points, two theory questions of 4 points, one Matlab question of 3 points. Time: 3 hours, as in the latest exam sheet. No documents allowed and no calculator: leave numbers such as or unevaluated unless the text asks for a decimal value. To pass you need at least 10 points in the exercises and at least 5 between theory and Matlab. For every question justify the answers and show all the calculations; when a sketch is requested, indicate the support (or the range) and the shape, even approximately. Compare with the results only at the end, then read the solutions and the grid.
The three exercises of this mock exam cover a continuous-time frequency response, the Z-transform and the DFT; the theory questions are on the scalar product and the Dirac impulse, the Matlab question on a moving-average filter.
Exercise 1 (points 7)
Frequency response of a continuous-time system. The causal LTI system has frequency response
- Compute the modulus and the phase and sketch them for , giving their values at , at rad/s and their limits for . Say whether is low-pass, high-pass or band-pass.
- Find the poles of (replace with ) and say whether is BIBO stable.
- The input is . Compute the output as a sum of sinusoids.
- Determine the two pulsations at which (the dB band), the width of the band and the value of the phase at and at .
Show the result
- and . (phase as ), (phase ), for : modulus and phase . Band-pass filter.
- Poles . Real part negative: is BIBO stable.
- .
- rad/s, rad/s; width rad/s ( Hz); , .
Show the full solution
Point 1. To read the shape of divide numerator and denominator by (for ): where we used . The function is real, so (modulus and phase of : the denominator has modulus and phase , see Complex NumbersReview of complex numbers: algebraic and polar forms, Euler's formula, powers and roots, the fundamental theorem of algebra, roots of unity, and why complex numbers cannot be ordered.Complex Numbers →). Special values:
- : , so : modulus (the maximum, because ) and phase . Directly from the original formula the numerator and the denominator coincide: .
- : , so and the phase . Indeed from the original formula (numerator , denominator ).
- : , so (like ) and the phase tends to .
The modulus is at both ends and in the middle, so the system rejects low and high pulsations and keeps those around rad/s: it is a band-pass filter (Frequency-Selective FiltersA convolutional LTI system filters by multiplying the input spectrum by H(j omega); ideal low-pass and high-pass filters, first-order RC implementations, distortion-free transmission (Heaviside conditions), why the ideal low-pass filter is not realizable, and the practical design parameters.Frequency-Selective Filters →, Introduction to FiltersA filter is an LTI convolutional BIBO-stable system that reshapes or removes harmonics of a signal; the differentiator and the RC low-pass filter show how H(j omega) is read from the differential equation, and the four popular selective filters are low-pass, high-pass, band-pass and band-stop.Introduction to Filters →). The phase decreases monotonically from to crossing at the centre pulsation. One more symmetry is useful: , so takes the same value at and at (it is symmetric on a logarithmic axis, which will be used in point 3).
Grafico interattivo: |H(jω)| per ω da 50 a 3000 rad/s: picco 1 in ω = 1000, zero agli estremi; la linea tratteggiata è il livello 1/√2 (3 dB) raggiunto in 904.99 e 1104.99 rad/s
Grafico interattivo: Fase di H(jω) in radianti: da +π/2 (ω piccolo) a −π/2 (ω grande), vale 0 in ω = 1000 e ±π/4 ai bordi della banda a 3 dB
Point 2. For a system described by (Frequency Response of LTI SystemsApplying the Fourier transform to LTI convolutional systems described by ODEs: the frequency response H(jw) is the transform of the impulse response, equals Y/U, is a ratio of polynomials in jw, and can be inverted by partial fractions to get h(t), with a warning about causality when the system is not asymptotically stable.Frequency Response of LTI Systems →) the poles are the roots of the denominator written in : here , so The two poles are complex conjugate with real part : the modes decay, so the system is asymptotically and BIBO stable (Stability of LTI Systems - BIBO and Internal StabilityCharacterization of BIBO (external) stability and of internal stability of LTI convolutional systems through the mode functions: stability zones in the complex plane, asymptotic, marginal and unstable behaviour of the natural response, and an example of an externally stable but internally unstable system with a zero-pole cancellation.Stability of LTI Systems - BIBO and Internal Stability →). For an asymptotically stable system is causal, in agreement with the text. Error to avoid: the zero of in does not matter for stability, only the poles do.
Point 3. The system is real, stable and is known, so each sinusoid is treated separately (Eigenfunctions and Frequency Response of LTI Systemsfor a BIBO stable convolutional LTI system the complex exponential e^{j w t} is an eigenfunction and the frequency response H(jw), the Fourier transform of the impulse response, is its eigenvalue; for real h the response to a cosine is a scaled and phase-shifted cosine.Eigenfunctions and Frequency Response of LTI Systems →): and, by linearity, the output is the sum of the outputs.
- Constant (): , so the constant is removed.
- : , so it passes unchanged: .
- : first the value of : Modulus: (the same value follows from : ). Phase: and is in the second quadrant, so ; the phase of the ratio is the difference The phase of the output sinusoid is .
Putting the three terms together: . Typical errors: using (wrong quadrant), forgetting that the constant is removed, or keeping the phase of the input out of the sum.
Point 4. The condition means , i.e. : The positive root of () is ; the positive root of () is (the other roots are negative and are not pulsations of the band). Between them and . The width is exactly and the product is (the geometric symmetry of point 1: the two edges are mapped into each other by ). The phase is : at , gives ; at , gives . Reminder: in modulus is the level of dB, i.e. half of the power.
Exercise 2 (points 7)
A digital filter and the Z-transform. A discrete-time LTI system has transfer function
- Find the poles and the zeros of and the difference equation that links the input and the output .
- List the possible regions of convergence (ROC) of and say, for each one, whether the corresponding impulse response is causal, anticausal or two-sided. Which ROC corresponds to a causal and BIBO stable system?
- For the causal system, compute the impulse response with partial fractions and write .
- For the causal system, compute the frequency response at and and the output for the input , .
- Find the sequence whose transform is with ROC . Is it causal? Is it BIBO stable?
Show the result
- Poles and ; zeros and (no cancellation, no pole or zero at the origin). .
- Three ROCs: (causal), (two-sided), (anticausal). Causal and stable: .
- ; , , , .
- and . .
- (for example , , ). Not causal, not BIBO stable.
Show the full solution
Point 1. Multiply numerator and denominator by to see poles and zeros as roots of polynomials in : Zeros , poles . No zero cancels a pole, and numerator and denominator have the same degree, so there is no pole or zero in or at infinity. The two zeros lie on the unit circle (this will matter in point 4).
Grafico interattivo: Piano z (ascissa Re z, ordinata Im z): circonferenza unitaria, poli in 1/2 e −1/4 (cerchio tratteggiato di raggio 1/2 e di raggio 1/4: i bordi delle tre ROC), zeri in 1 e −1 sulla circonferenza unitaria
For the equation, with the delay (Unilateral Z-Transform and Difference EquationsThe unilateral Z-transform X(z) = sum_{k>=0} x(k) z^{-k} handles initial conditions through its shift formulas, so it solves ARMA difference equations (natural response plus forced response H(z)U(z)); the transfer function H(z) is the Z-transform of the causal impulse response and BIBO stability means all poles inside the unit circle.Unilateral Z-Transform and Difference Equations →, Difference EquationsRecursive constant-coefficient linear difference equations (ARMA models) are the discrete-time counterpart of ODEs: the delay operator replaces the derivative, the modes are k^m lambda^k with lambda a root of the characteristic polynomial, and the solution splits into a natural and a forced response.Difference Equations →). The denominator expanded is , so
Point 2. The ROC of a bilateral Z-transform is an annulus bounded by the poles and contains no pole (Bilateral Z-TransformThe bilateral Z-transform X_B(z) = sum x(k) z^{-k} is the discrete-time counterpart of the Laplace transform; it converges only on a region of convergence (an annulus-type region), extends the DTFT when the unit circle is in the ROC, has an inversion formula and properties such as linearity, shift, time reversal and convolution.Bilateral Z-Transform →). The poles have moduli and , so the plane is split into three regions:
- : exterior of a circle, causal sequence (right-sided: for );
- : annulus, two-sided sequence (one pole gives a causal part and the other an anticausal part);
- : interior of a disc, anticausal sequence ( for ).
BIBO stability is , which is equivalent to having the unit circle inside the ROC (Stability of LTI Systems - BIBO and Internal StabilityCharacterization of BIBO (external) stability and of internal stability of LTI convolutional systems through the mode functions: stability zones in the complex plane, asymptotic, marginal and unstable behaviour of the natural response, and an example of an externally stable but internally unstable system with a zero-pole cancellation.Stability of LTI Systems - BIBO and Internal Stability →, Bilateral Z-TransformThe bilateral Z-transform X_B(z) = sum x(k) z^{-k} is the discrete-time counterpart of the Laplace transform; it converges only on a region of convergence (an annulus-type region), extends the DTFT when the unit circle is in the ROC, has an inversion formula and properties such as linearity, shift, time reversal and convolution.Bilateral Z-Transform →). Among the three ROCs only the first contains , and it is also the ROC of a causal system. So the causal system is stable, as expected: all its poles are inside the unit circle.
Point 3. Work with and write . Numerator and denominator have the same degree in , so first extract the constant (the limit for , i.e. the ratio of the leading coefficients ): The coefficients are obtained by the cover-up rule: and . Check at : . Using for and : Values: ; ; ; . Check with the difference equation of point 1 for : , , , (the term acts only at ). Check of the area: and indeed . A very common error is forgetting the constant and writing only the two exponentials: then instead of .
Point 4. The unit circle is in the ROC, so is evaluated on (Bilateral Z-TransformThe bilateral Z-transform X_B(z) = sum x(k) z^{-k} is the discrete-time counterpart of the Laplace transform; it converges only on a region of convergence (an annulus-type region), extends the DTFT when the unit circle is in the ROC, has an inversion formula and properties such as linearity, shift, time reversal and convolution.Bilateral Z-Transform →, FIR and IIR FiltersDiscrete-time (digital) filters are described by ARMA difference equations; FIR filters have finite impulse response (moving average, no auto-regression), IIR filters have auto-regression and a rational frequency response; worked examples of a first-order IIR low-pass/high-pass filter and a moving-average FIR low-pass filter.FIR and IIR Filters →): For the numerator is ; for , and again . So the filter removes the constant component and the component at the highest frequency (the denominator does not vanish there): it is band-pass.
The input is , a sum of two sinusoids, and the output of a stable system is computed term by term (Eigenfunctions and Frequency Response of LTI Systemsfor a BIBO stable convolutional LTI system the complex exponential e^{j w t} is an eigenfunction and the frequency response H(jw), the Fourier transform of the impulse response, is its eigenvalue; for real h the response to a cosine is a scaled and phase-shifted cosine.Eigenfunctions and Frequency Response of LTI Systems →, discrete-time part): . For use and : since . Modulus , phase (the numerator is real and positive). Therefore The result holds for every because the input is defined for all (for an input switched on at it holds after the transient, which decays like ).
Grafico interattivo: |H(e^{jθ})| per θ tra 0 e π: zero in θ = 0 e in θ = π (zeri sulla circonferenza unitaria), massimo 16/9 ≈ 1.78 vicino a θ ≈ 1.28, vale 16/√85 ≈ 1.735 in θ = π/2
Point 5. The partial fractions of point 3 do not depend on the ROC: . What changes is the inverse of each term, which must be consistent with the ROC :
- has its pole at , of modulus , and the ROC lies outside that circle (): causal, , as before;
- needs : anticausal, for (Bilateral Z-TransformThe bilateral Z-transform X_B(z) = sum x(k) z^{-k} is the discrete-time counterpart of the Laplace transform; it converges only on a region of convergence (an annulus-type region), extends the DTFT when the unit circle is in the ROC, has an inversion formula and properties such as linearity, shift, time reversal and convolution.Bilateral Z-Transform →).
Hence Values: , , ; ; , . The sequence is not zero for , so it is not causal, and grows, so : not BIBO stable. It is consistent with the fact that the unit circle is not in the ROC (the DTFT of does not exist). Same formula , different sequences: the ROC is part of the transform.
Exercise 3 (points 7)
DFT of a short sequence, zero padding, resolution. Let be the sequence with , , , and for all other . Use the DFT of the course, , and write for the DTFT of .
- Write and compute , and .
- Compute by hand the DFT on points , , and check its relation with .
- The sequence is completed with four zeros (length ). Compute for and say how is related to and to .
- Verify Parseval's relation for the DFT with and with .
- Let . (a) The signal is observed on samples and the DFT is computed after zero padding to points: can the two frequencies be seen as two separate peaks? (b) Using as resolution limit that two components can be told apart only if their frequencies (in cycles per sample) differ by at least , find the smallest number of samples that resolves them and compute the DFT of those samples.
Show the result
- ; , , .
- , and .
- , i.e. , . and .
- (with and ).
- (a) No: with the resolution is and the two lines merge in one broad peak near ; the zero padding only interpolates. (b) ; and all the other values are .
Show the full solution
Point 1. The sequence has only four non-zero samples, so the sum of the definition (Discrete-Time Fourier TransformThe DTFT of an aperiodic discrete-time signal is the 2pi-periodic function X(e^{j theta}) = sum x(k) e^{-j theta k}; it is obtained as the envelope of the DFT of the N-periodic repetition when N tends to infinity, and has translation, modulation, convolution and Parseval properties.Discrete-Time Fourier Transform →) has four terms: (the sum of the samples). For : , , so . For : and , so (the alternating sum of the samples is zero).
Grafico interattivo: |X(θ)| nel periodo [0, 2π]: vale 2 in θ = 0 e 2π, √10 ≈ 3.16 in θ = π/2 e in 3π/2, zero in θ = π. I campioni della DFT a 4 punti sono 4|X4(k)| = |X(kπ/2)| e quelli a 8 punti 8|X8(k)| = |X(kπ/4)|
Point 2. Here the number of samples equals , so there is no padding. For the exponential is and the powers of are . Then where for the exponents give . Control: is real, so (symmetry of the DFT of a real signal). Relation with the DTFT: the DFT of the periodic repetition of is the DTFT sampled at and divided by (Discrete-Time Fourier TransformThe DTFT of an aperiodic discrete-time signal is the 2pi-periodic function X(e^{j theta}) = sum x(k) e^{-j theta k}; it is obtained as the envelope of the DFT of the N-periodic repetition when N tends to infinity, and has translation, modulation, convolution and Parseval properties.Discrete-Time Fourier Transform →): . Indeed , and . The inverse formula gives back, e.g., (Discrete Fourier TransformHeuristic derivation of the discrete Fourier transform for N-periodic discrete-time signals: complex exponentials with period N, the finite basis of N modes obtained from the difference equation x(k)-x(k-N)=0, orthogonality, the coefficient formula and the definition of the DFT with its periodicity and matrix form.Discrete Fourier Transform →).
Point 3. With the four extra zeros nothing changes in the sum, only the evaluation points: for Even values of are points already computed (): , , , . The odd values are new points. For : and , so For : and , so The last three values follow from the symmetry of the DFT of a real signal, : , . So (the factor comes from instead of ) and the odd are 4 new samples of the same curve : zero padding does not add information, it only samples the same DTFT more densely (Properties of the Discrete Fourier Transformthe DFT with its inverse, translation and modulation properties, the correspondence between cyclic convolution and product, Parseval's relation, and the example of a periodic rectangular pulse train whose DFT is a Dirichlet kernel.Properties of the Discrete Fourier Transform →). Typical error: believing that the padded DFT is "more precise" and getting different values at the even points.
Point 4. The energy is . Parseval for the DFT with the factor in the forward formula is (Properties of the Discrete Fourier Transformthe DFT with its inverse, translation and modulation properties, the correspondence between cyclic convolution and product, Parseval's relation, and the example of a periodic rectangular pulse train whose DFT is a Dirichlet kernel.Properties of the Discrete Fourier Transform →). For : and . For : gives , , , , , , , (for odd : and ), whose sum is , so and ✓. Both give the energy : padding with zeros does not change the energy.
Point 5. (a) A signal observed on samples is the product of the infinite sinusoids and a rectangular window of length , so each cosine becomes a Dirichlet-like kernel in frequency (Discrete-Time Fourier TransformThe DTFT of an aperiodic discrete-time signal is the 2pi-periodic function X(e^{j theta}) = sum x(k) e^{-j theta k}; it is obtained as the envelope of the DFT of the N-periodic repetition when N tends to infinity, and has translation, modulation, convolution and Parseval properties.Discrete-Time Fourier Transform →, example of the discrete rectangle), whose main lobe extends up to the first zero at (in cycles per sample). For the half-width of the main lobe is , larger than the distance between the two frequencies: the two lobes overlap and sum to one broad peak (a numerical check with gives a single maximum at ). Zero padding to makes the spacing between the computed points , but it does not narrow the lobes: the resolution depends on the number of observed samples , not on the padded length .
(b) The condition gives , so the smallest is . With the frequencies are exactly bin frequencies: and . Writing the cosines with Euler's formulas, which is already a sum of the harmonics of the DFT, with and (index modulo ). By orthogonality of the harmonics (Discrete Fourier TransformHeuristic derivation of the discrete Fourier transform for N-periodic discrete-time signals: complex exponentials with period N, the finite basis of N modes obtained from the difference equation x(k)-x(k-N)=0, orthogonality, the coefficient formula and the definition of the DFT with its periodicity and matrix form.Discrete Fourier Transform →) the coefficients are read directly: and elsewhere (there is no leakage, because both cosines complete an integer number of periods, and , in the window). Control with Parseval: , and the signal power is per sample, i.e. energy ✓.
Theory 1 (points 4)
Scalar product, orthogonality and complex exponentials. (1) Define the scalar product on a complex vector space and the associated norm and orthogonality; give the scalar product of the space of finite-energy signals on an interval of length . (2) Let and , . Prove that . (3) Use it to obtain the formula for the coefficients of and the energy of over one period. (4) State the discrete-time analogue for the signals .
Show the result
, , . . and . Discrete time: (indices modulo ).
Show the full solution
Definitions (Vector Spaces, Scalar Product and NormsReview of geometry for signals: vector spaces over a field, the scalar product and norm in complex vector spaces, p-norms, orthogonality, and the generalized Pythagorean theorem.Vector Spaces, Scalar Product and Norms →, Hilbert SpacesA Hilbert space is a complete scalar-product space; C^N, l^2 and L^2(S) are Hilbert spaces, and the scalar product in l^2 and L^2 is what engineers call mutual energy.Hilbert Spaces →). A scalar product on a complex vector space is a map with three properties: conjugate symmetry ; linearity in the first argument, ; positivity with equality only for . The norm is and means . On the scalar product is the mutual energy over the interval, , and the norm squared is the energy (in it is ).
Orthogonality (Continuous-Time Fourier SeriesA periodic continuous-time signal is written as a combination of harmonics e^{jn w0 t} whose coefficients a_n are projections of the signal onto each harmonic; coefficients have symmetries that mirror those of the signal.Continuous-Time Fourier Series →). Take (the result does not depend on the interval of length ): If the integrand is and the integral is . If , with the antiderivative exists because : because and is an integer: the exponential completes a whole number of periods. So the are orthogonal, with . (Without the conjugate in the scalar product one would get only for : the conjugate is essential.)
Coefficients and energy. If , by linearity in the first argument is the projection of on the -th harmonic, divided by . For the energy, expand and keep only the terms : (the generalized Pythagorean theorem for orthogonal vectors; this is Parseval's relation for the Fourier series, Properties of the Fourier SeriesThe Fourier coefficient map is a linear isometry between L2 over a period and l2 (Parseval identity, power equals the sum of squared coefficient moduli), and it turns time shift, modulation, conjugation, reversal, scaling and product into simple operations on the coefficients.Properties of the Fourier Series →).
Discrete time (Discrete Fourier TransformHeuristic derivation of the discrete Fourier transform for N-periodic discrete-time signals: complex exponentials with period N, the finite basis of N modes obtained from the difference equation x(k)-x(k-N)=0, orthogonality, the coefficient formula and the definition of the DFT with its periodicity and matrix form.Discrete Fourier Transform →). The signals , , have . For every term is and the sum is ; for the ratio satisfies , so the finite geometric sum is . Hence , and the coefficients are .
Example: with , while . Typical errors: forgetting the conjugate; forgetting that the interval must be a whole period; writing in the scalar product (it belongs to the formula of , not to the scalar product).
Theory 2 (points 4)
The Dirac impulse. (1) Define the Dirac impulse as a generalized function through the sifting property and explain why " and elsewhere" is not a definition. (2) Construct it as the limit of the rectangles for and elsewhere, and prove that for every continuous . (3) Prove the scaling property , , in integral form, and the sampling property . (4) Compute and , where is the unit step.
Show the result
Sifting: . . . and .
Show the full solution
Point 1 (Continuous-Time Unit Step and Dirac Impulsethe continuous unit step and the Dirac impulse defined as a generalized function through the sifting property, three constructions as limits (rectangular, Gaussian, sinc), the convergence theorem for continuous signals and the properties of the impulse.Continuous-Time Unit Step and Dirac Impulse →, Linear Functionalsa linear functional maps a vector space of signals to numbers and respects linear combinations; examples are the scalar product, the area and the mean value, while the energy is not linear.Linear Functionals →). The Dirac impulse is not an ordinary function: it is defined by what it does inside an integral, namely by requiring, for every signal continuous in , This defines the linear functional . The naive definition is wrong because a function equal to except at one point has integral , not (no ordinary function can have the sifting property), and is not a value that can be integrated.
Point 2. The rectangle has height on an interval of width , so the area is for every . For continuous , the mean value theorem gives a point with because and is continuous. This convergence "in distribution" (limit of the integrals, not of the functions) defines . With we get the unit area, .
Point 3. Scaling: with substitute , . If the limits stay ; if they are swapped, and swapping them back changes the sign of : in both cases the factor is : so (with : is even). Sampling: for any test signal continuous in , that is (only the value of at matters).
Point 4. Write by scaling and shift, and sift at : The factor is the typical thing to forget. For the step: , because multiplying the argument of the step by a positive number does not change it, and . So the result is ; with the chain rule one finds the same: .
Matlab 1 (points 3)
Moving-average filter: design, application and frequency response. Consider , , and the moving-average filter of length , (with for ). The component at cycles per sample must be completely removed. Write a Matlab script that:
- generates ;
- computes the smallest that cancels the component at (explain how is chosen) and applies the filter to ;
- plots and in one figure;
- plots in a second figure the modulus of the frequency response of the filter for , computed with the FFT with zero padding to points, with a correct frequency axis, together with the theoretical curve, and marks the two frequencies and .
Show the result
(the zeros of are at and ). Output in steady state (): : the second component is removed, the first has gain and a delay of samples. Script in the solution.
Show the full solution
Design of . The impulse response is for (FIR and IIR FiltersDiscrete-time (digital) filters are described by ARMA difference equations; FIR filters have finite impulse response (moving average, no auto-regression), IIR filters have auto-regression and a rational frequency response; worked examples of a first-order IIR low-pass/high-pass filter and a moving-average FIR low-pass filter.FIR and IIR Filters →), so the frequency response is a geometric sum: (the trick in numerator and denominator). Its modulus vanishes at , . The component at is removed exactly if is an integer: (), and also work; the smallest is . The gain on the useful component is and the phase , i.e. a delay of samples (Eigenfunctions and Frequency Response of LTI Systemsfor a BIBO stable convolutional LTI system the complex exponential e^{j w t} is an eigenfunction and the frequency response H(jw), the Fourier transform of the impulse response, is its eigenvalue; for real h the response to a cosine is a scaled and phase-shifted cosine.Eigenfunctions and Frequency Response of LTI Systems →): after the transient of samples, .
Script.
%% MOVING-AVERAGE FILTER - DESIGN, APPLICATION, FREQUENCY RESPONSE
clear all; close all; clc;
%% 1. Signal
n = 0:99; % time index
nu1 = 0.02; nu2 = 0.4; % normalized frequencies [cycles/sample]
x = cos(2*pi*nu1*n) + 0.5*cos(2*pi*nu2*n);
%% 2. Design and application of the filter
% |H| vanishes at nu = k/M, so we need M*nu2 integer: nu2 = 2/5 -> M = 5
M = 5;
b = ones(1, M)/M; % h(n) = 1/M, n = 0..M-1
y = filter(b, 1, x); % zero initial conditions (x(n) = 0, n < 0)
%% 3. Input and output
figure(1);
plot(n, x, 'o-', 'LineWidth', 1); hold on;
plot(n, y, 's-', 'LineWidth', 1.5); hold off; grid on;
xlabel('n'); ylabel('amplitude'); legend('x(n)', 'y(n)');
title('Moving average with M = 5');
%% 4. Frequency response with the FFT and zero padding
Nfft = 1024;
Hf = fftshift(fft(b, Nfft)); % fft(b,Nfft) pads b with zeros up to Nfft
nu = (-Nfft/2 : Nfft/2-1)/Nfft; % axis in cycles/sample, from -1/2 to 1/2 - 1/Nfft
g = @(v) abs(sin(pi*M*v) ./ (M*sin(pi*v))); % theoretical modulus
Hth = g(nu); Hth(nu == 0) = 1; % the formula is 0/0 in nu = 0, where H = 1
figure(2);
plot(nu, abs(Hf), 'LineWidth', 1.5); hold on;
plot(nu, Hth, '--', 'LineWidth', 1.5);
plot([nu1 nu2], g([nu1 nu2]), 'ro', 'MarkerFaceColor', 'r'); hold off; grid on;
xlabel('\nu [cycles/sample]'); ylabel('|H|');
legend('FFT', 'theory', '\nu_1 = 0.02 and \nu_2 = 0.4');Comments on the choices. fft(b, Nfft) pads with zeros and returns at directly, without the factor of the DFT of the course, because is a DTFT (a sum, not an average): the check is that the value at is . fftshift puts in the centre, and the axis (-Nfft/2:Nfft/2-1)/Nfft is the one that matches the shifted vector (without it the axis would run from to and the negative frequencies would appear at the end). With the Signal Processing Toolbox freqz(b,1,Nfft,'whole') gives the same values. In the figure the FFT and the theoretical curve coincide, the curve has zeros at and and the red circles sit at for and exactly for .
Grafico interattivo: |H| del filtro a media mobile con M = 5 per ν tra −1/2 e 1/2: vale 1 in ν = 0, zeri in ±0.2 e ±0.4, lobi laterali piccoli (massimo 0.25 tra 0.2 e 0.4 e 0.2 in ν = 0.5); 0.984 in ν = 0.02 e 0 in ν = 0.4
Self-assessment grid
| Exercise | Points | What must be there for full marks | Typical errors |
|---|---|---|---|
| 1 | 7 | 2: and with , values at , , , band-pass. 1: poles , stable. 2: gains , , , phase , output with three terms handled separately. 2: , , width , phases | wrong quadrant for ; the constant not removed; instead of for the dB points; stability judged from the zero of |
| 2 | 7 | 1.5: poles , zeros , difference equation. 1: three ROCs with their meaning and the unit circle criterion. 1.5: constant , coefficients and , , , , . 1.5: zeros of at and , , output with the DC term removed. 1.5: with the anticausal term , not causal, not stable | forgetting the constant term of the partial fractions; same inverse for every ROC; poles inside the unit circle used for the ROC without checking; with a sign mistake in |
| 3 | 7 | 1: , , , . 1.5: and . 1.5: all the with the odd values from , , and . 1: Parseval with and . 2: resolution depends on not on , , DFT with four values at | missing factor ; sign of the exponent; without the factor ; believing that zero padding improves the resolution |
| Theory 1 | 4 | 1: scalar product axioms, norm, orthogonality, . 1.5: proof of with . 1: and . 0.5: discrete-time analogue | missing conjugate; interval not a period; factor misplaced |
| Theory 2 | 4 | 1: sifting definition and why is not enough. 1: rectangles and mean value theorem. 1: scaling with and sampling. 1: and | factor forgotten (result ); treated as a function; no justification of the limit |
| Matlab 1 | 3 | 1: signal and filter with justified by the zeros at . 1: plot of and . 1: FFT with zero padding, fftshift and axis in , theoretical curve, two marked frequencies |
frequency axis from to after fftshift; factor in the FFT of ; chosen by trial; sin formula undefined in |