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.

test_fastconv3.m
```% This program tests function fastconv3.m to ensure its proper functionality.

clear; clc; close all;

N1 = 23; N2 = 64;
n = -N1:N2;  % Time indices for sequence x[n].

M1 = 16; M2 = 45;
m = -M1:M2; % Time indices for sequence y[m].

% Assign random values to both sequences:
x = randn(1,length(n))  + 1i*randn(1,length(n));
y = randn(1,length(m)) + 1i*randn(1,length(m));

[nz z] = fastconv3(x,y,n,m);  % vector k contains the time indices of the convolution sequence.

z1 = conv(x,y);

%% Plot the results.

figure(1);
subplot(3,1,1);
stem(n,real(x));
grid; axis tight;
title('Sequence \Ree\{x[n]\}');

subplot(3,1,2);
stem(m,real(y),'rx');
grid; axis tight;
title('Sequence \Ree\{y[n]\}');

subplot(3,1,3);
stem(nz,real(z));
grid; axis tight;
hold on
stem(nz,real(z1),'m.');
title('\Ree\{x[n]\asty[n]\} calculated by fastconv3.m (blue circles) and MatLab conv.m (magenta dots)');

figure(2);
subplot(3,1,1);
stem(n,imag(x));
grid; axis tight;
title('Sequence \Imm\{x[n]\}');

subplot(3,1,2);
stem(m,imag(y),'rx');
grid; axis tight;
title('Sequence \Imm\{y[n]\}');

subplot(3,1,3);
stem(nz,imag(z));
grid; axis tight;
hold on
stem(nz,imag(z1),'m.');
title('\Imm\{x[n]\asty[n]\} calculated by fastconv3.m (blue circles) and MatLab conv.m (magenta dots)');
```