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_IDCT(X)
% Inverse Discrete Cosine Transform Computation.
% This function computes the inverse DCT of a real or complex input signal X[k]
% stored in vector X by use of it's relationship with the DFT.
% Attention: Length of X should be even.
% First convert input vector X to a row vector for subsequent processing:
X = X(:).';
N = length(X);
x = zeros(1,N);
if isreal(X) % Execute this branch if Input vector X is real.
X = [sqrt(N)*X(1) sqrt(2*N)*X(2:end)];
% Create the phasor:
k = 0:N-1;
phasor = exp(1i*pi*k/(2*N));
% Multiply the first N elements of Y with the complex phasor.
X1 = real(ifft(phasor.*X));
% De-interleave the result:
x(2*n-1) = X1(n);
x(2*n) = X1(N+1-n);
else % if X is complex...
% Create the "inverse" phasor with appropriate scaling:
k = 0:N-1;
phasor = sqrt(2*N)*exp(1i*k*pi/(2*N));
phasor(1) = phasor(1)*sqrt(2);
% Multiply the elements of X with the complex phasor:
Y = zeros(1,2*N);
Y(1:N) = phasor.*X;
Y(N+2:2*N) = -1i*phasor(2:N).*fliplr(X(2:N));
y = ifft(Y); % Take the 2N-point inverse DFT of the new sequence.
x = y(1:N); % Keep only the first N samples.