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.

my_CZT(x,M,W,A)
function X = my_CZT(x,M,W,A)
% Fast chirp z-transform (CZT) computation.
% The method indicated in the paper "The Chirp z-transform Algorithm"
% by Rabiner, Schafer and Rader (1969) is employed.
% Inputs:
% A : a complex number representing the starting point of the CZT on the z-plane.
% W: this is the step between 2 points on the z-plane where the transorm will be computed.
% M: the number of points (or length) of the chirp z-transform.
% x: a vector containing the signal to be tranformed.

% Make sure x is a row vector:
x = x(:).';

N = length(x);
L = 2^nextpow2(M+N-1); % We choose L as a power of two and L>=N+M-1.
n = 0:N-1;
k = 0:M-1;
n1 = L-N+1:L-1;
L1 = L*ones(1,N-1);

% Step 1. Form an L-point sequence y[n]:
y = [ x.*(A.^(-n)).*W.^(n.^2/2)   zeros(1,L-N)];

% Step 2. Define an L-point sequence v[n] as follows:
v = [ W.^(-k.^2/2)  zeros(1,L-(N+M-1))  W.^(-(L1-n1).^2/2)];

% Step 3. Calculate the convolution using the fft and ifft.
g = fastconv(y,v);

% Step 4. Multiply by the W^(k^2/2) factor.
X = W.^(k.^2/2).*g(1:M);

Contact us