Code covered by the BSD License

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

### Ilias Konsoulas (view profile)

29 Oct 2012 (Updated )

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

fastconv2(x,y)
```function z = fastconv2(x,y)
% Compute a linear convolution via DFT's.
% This method cannot be applied for on-line convolution computation.
% This function takes care of the sizes of the 2 input sequences  and zero-pads them
% to a common length L = 2^n. This is the only difference with fastconv.m
% where zero-padding to appropriate lengths must be arranged externally.

% Make sure x and y are row vectors.
x = x(:).';
y = y(:).';

N = length(x);
M = length(y);
L  = 2^nextpow2(N+M-1);

x1 = [x zeros(1,L-N)];  % Zero-pad as required to make the length
y1 = [y zeros(1,L-M)];  % of both sequences equal to L=2^n for max fft() performance.

X = fft(x1);
Y = fft(y1);

Z = X.*Y;

z1 = ifft(Z);

% return only the values within the range of the linear convolution.
z = z1(1,1:N+M-1);```