Q&A (Labs 4&5)
School of Architecture, Civil and
Environmental Engineering
EPFL, SS 2009-2010
http://disal.epfl.ch/teaching/signals_instruments_systems/
Outline
• Lab 4 Concepts:
– Discrete signals, signal processing in Matlab
– Convolution
– Fourier series
• Lab 5 Concepts:
– High- / Low- pass filter
– Bode diagrams
Discrete Convolution
m
m
mgmnftgf )()()(
Indeces:
n: shift of reflected signal
m: sum over m of multiplied values
Example: Moving Average
Ex.: Moving Average II
L = 5 L = 20 L = 60
L
1/Lsignal ‘rect’:
This moving average is a convolution of rectangular signal (of length L) with
a noisy sinus signal. Does this look like a filter? If yes, which one?
Moving Average in Frequency and
Time-Domain
signalrect
)()( signalfftrectfft
time-domain
frequency-domain
-10 -8 -6 -4 -2 0 2 4 6 8 10-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
-1 -0.8-0.6-0.4-0.2 0 0.2 0.4 0.6 0.8 1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
-10 -8 -6 -4 0 2 4 6 8 10
0.2
0.4
0.6
0.8
1
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
0.2
0.4
0.6
0.8
1
The result is equivalent!
Using Matlab
% moving average example
clear; figure; hold;
xs = 0:100;
ys = 1*sin(xs*0.1) + 0.5*sin(xs) +
0.9*sin(xs*2.3);
plot(ys,'k','LineWidth',2);
xf = 0:10;
l = 60;
yf = repmat((1/l),1,l);
yc = conv(yf,ys);
plot(yc,'r','LineWidth',2);
legend('Original signal','Convolution');
Using Matlab
% moving average example
clear; figure; hold;
xs = 0:100;
ys = 1*sin(xs*0.1) + 0.5*sin(xs) +
0.9*sin(xs*2.3);
plot(ys,'k','LineWidth',2);
xf = 0:10;
l = 60;
yf = repmat((1/l),1,l);
yf = [repmat(0,1,20), yf];
yc = conv(yf,ys);
plot(yc,'r','LineWidth',2);
legend('Original signal','Convolution');
The rectangular signal is shifted (the origin is at position i=21).
The origin of the convolution is (i+j-1)=(21+0-1)=20.
Lab 5 – Q2, Q3
Original signal and its FFT
In Matlab, the resulting
FFT amplitude is A*n/2,
where A is the original
amplitude and n is the
number of FFT points.
Lab 5 – Q2, Q3
2Hz sampling
Lab 5 – Q2, Q3
4Hz sampling
Lab 5 – Q2, Q3
20Hz sampling
What does the Nyquist-Shannon
theorem say?
Lab 5 – Q4
Original signal
Lab 5 – Q4
What is this effect called?
Can you explain the FFT peak at 3Hz?
Lab 5 – Q5
Original signal
Lab 5 – Q5
10Hz sampling, low-pass with 3Hz cutoff
Lab 5 – Q5
Bode plot
Lab 5 – Q7
10Hz sampling, 1st order BW low-pass with 3Hz cutoff
Lab 5 – Q7
10Hz sampling, 3rd order BW low-pass with 3Hz cutoff
Lab 5 – Q7
~1*20dB ~3*20dB
1st order 3rd order
attenuation per decade ~ n*20dB
Lab 5 – Q8
Butterworth of order n: attenuation per decade ~ n*20dB
Lab 5 – Q12,Q13
freq
uen
cy
frequency
amplitude
What is the FT of a rectangular function? And in 2D?