DSP Lab 03
DSP Lab 03
2. Resources Required
• A computer
• MATLAB 7.0 or higher
3. Difference Equation:
The difference equation is a formula for computing an output sample at time based on past and
present input samples and past output samples in the time domain. We may write the general,
causal, LTI difference equation as follows:
𝑦(𝑛) = 𝑏0𝑥(𝑛) + 𝑏1𝑥(𝑛 − 1) + ⋯ + 𝑏𝑀𝑥(𝑛) − 𝑎1𝑦(𝑛 − 1) − ⋯ − 𝑎𝑁𝑦(𝑛 − 𝑁)
𝑀 𝑁
Cross-correlation can be used to compute the impulse response h(n) of a filter from the cross-
correlation of its input and output signals x(n) and y(n) = x(n)*h(n) , respectively. To see this, note
that, by the correlation theorem,
𝑥 ⋆ 𝑦 ⇔ 𝑋̅ ∙ 𝑌 = 𝑋̅ ∙ (𝐻 ∙ 𝑋) = 𝐻 ∙ |𝑋|2
Therefore, the frequency response equals the input-output cross-spectrum divided by the input
power spectrum:
𝑋̅ ⋅ 𝑌 𝑅̂𝑥𝑦
𝐻= =
|𝑋|2 𝑅̂𝑥𝑥
where multiplication and division of spectra are defined point wise, i.e.,
2
𝐻(𝑤𝑘) = 𝑋(𝑤𝑘 ) ∙ 𝑌(𝑤𝑘 )/|𝑋(𝑤𝑘) |
err = norm(Hxy-fft([h,zeros(1,Nfft-Nh)]))/norm(h);
disp(sprintf(['Frequency Response Error = ',...
'%0.14f%%'],100*err));
Output of LTI system y(n) can be computed by convolving the input signal x(n) with system
response h(n).
One method to implement is a fast convolution method which includes fft of signal and system
response.
For much longer convolutions, the savings become enormous compared with “direct'' convolution.
This happens because direct convolution requires on the order of 𝑁 2 operations (multiplications
and additions), while FFT-based convolution requires on the order of 𝑁𝑙𝑜𝑔(𝑁) operations, where
𝑙𝑜𝑔(𝑁) denotes the logarithm-base-2 of 𝑁.
8. Lab Task:
2. Write a code for convolution process using convolution as an inner product (hint: use
toeplitz matrix or convmtx for help)
3. In system identification code why we are using zero padding, what will be the output if we
don’t use zero padding?