Code covered by the BSD License  

Highlights from
MatLab Solutions: "Introduction to Digital Signal Processing: A Computer Laboratory Textbook".

image thumbnail

MatLab Solutions: "Introduction to Digital Signal Processing: A Computer Laboratory Textbook".

by

 

29 Oct 2012 (Updated )

These files are the MatLab solutions of exercises contained in the above DSP lab textbook.

diffft(x)
function X = diffft(x)
% Decimation-In-Frequency (DIF) FFT.
% Length of input signal x should be even.
N = length(x);
g = zeros(1,N/2);
h = zeros(1,N/2);

% Create sequences g[n] and h[n]:
for i=1:N/2
     g(i) = x(i) + x(i + N/2);
     h(i) = (x(i) - x(i + N/2))*exp(-1i*2*pi*(i-1)/N);
end

% Compute their N/2-point DFT:
% G = fft(g);
% H = fft(h);
% or you may use a custom function:
G = radix4fft(g);
H = radix4fft(h);

X = zeros(1,N); 
X(2:2:N)     = H;  % odd part
X(1:2:N-1) = G;  % even part

Contact us