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.
function X = my_DCT(x)
% Discrete Cosine Transform Computation.
% This function computes the DCT of a real or complex input signal x[n]
% stored in vector x by use of it's relationship with the DFT.
% First convert input vector x to a row vector for subsequent processing:
x = x(:).';
N = length(x);
% Create the following symmetric sequence y[n] = x[n] + x[2N-n-1].
x1 = [x fliplr(x)];
Y = fft(x1); % Take the 2N-point DFT of the new sequence.
k = 0:N-1;
phasor = exp(-1i*pi*k/(2*N));
% Multiply the first N elements of Y with the complex phasor.
X = real(phasor.*Y(1:N));
X = phasor.*Y(1:N);
% Scale as necessary to make it consistent with the MatLab dct.m function.
X = [1/(2*sqrt(N))*X(1) 1/sqrt(2*N)*X(2:end)];