MatLab Solutions: "Introduction to Digital Signal Processing: A Computer Laboratory Textbook".
29 Oct 2012
25 Nov 2013)
These files are the MatLab solutions of exercises contained in the above DSP lab textbook.
|fraction_delay3(x, h1, M, L)
function y = fraction_delay3(x, h1, M, L)
% This function induces a fractional sample delay by M/L to the input signal x.
% x: vector containing the signal that is going to undergo a fractional delay.
% h1: vector containing a low-pass filter necessary for the interpolator section.
% M: the numerator of the fractional delay factor.
% L: the denominator of the fractional delay factor. Caution: 0 < M < L in order for this to work.
% y: vector containing the signal x[n] delayed by M/L sample(s).
% First Interpolate x[n] by a factor of L:
% Note: Lowpass filter h1 has cutoff freq. = pi/L and Gain = L.
r = interpolator(x,h1,L);
% Delay the whole upsampled sequence by M samples:
% r = [zeros(1,M) r]; % This creates r(n-M);
r1 = shiftright(r,M); % This creates r(n-M);
% Lowpass filter h2 must have the same cutoff frequency as h1 and Gain = 1.
h2 = h1/L;
% Finally, decimate by a factor of L:
y = decimator(r1,h2,L);