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.

ex635b.m
% Exercise 6.3.5.b. Two-for-One FFT.

clc; clear; close all;

%% Generate 2 real, random signals of common size:
N = 64;
x = randn(1,N);
y = randn(1,N);

% Now compute their DFT using custom function fft241.m:
[X Y] = fft241(x,y);

X1 = fft(x);
Y1 = fft(y);

% Plot the real and imaginary parts of the FFT of x[n]:
k = 0:N-1;
figure('Name',' Exercise 6.3.5.b. Two-for-One FFT');
subplot(2,1,1);
stem(k,real(X));
title('\Ree\{X[k]\} using custom function fft241() (circles) and built-in function fft() (dots)');
xlabel('Frequency Sample Number k');
axis tight;
grid on;
hold on;

subplot(2,1,2);
stem(k,imag(X),'r');
title(['\Imm\{X[k]\} using custom function fft241() (circles) and built-in function fft() (dots)']);
xlabel('Frequency Sample Number k');
axis tight;
grid on;
hold on;

% Now compare the results by plotting them altogether.
subplot(2,1,1);
stem(k,real(X1),'b.');
axis tight;
grid on;

subplot(2,1,2);
stem(k,imag(X1),'r.');
axis tight;
grid on;

% Plot the real and imaginary parts of the FFT of y[n]:
figure('Name',' Exercise 6.3.5.b. Two-for-One FFT');
subplot(2,1,1);
stem(k,real(Y));
title('\Ree\{Y[k]\} using custom function fft241() (circles) and built-in function fft() (dots)');
xlabel('Frequency Sample Number k');
axis tight;
grid on;
hold on;

subplot(2,1,2);
stem(k,imag(Y),'r');
title(['\Imm\{Y[k]\} using custom function fft241() (circles) and built-in function fft() (dots)']);
xlabel('Frequency Sample Number k');
axis tight;
grid on;
hold on;

% Now compare the results by plotting them altogether.
subplot(2,1,1);
stem(k,real(Y1),'b.');
axis tight;
grid on;

subplot(2,1,2);
stem(k,imag(Y1),'r.');
axis tight;
grid on;

Contact us