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.

ex612.m
% Exercise 6.1.2. Direct DFT Evaluation.
% This script demonstrates the DFT calculation time needed
% when the definition formula is used.
clc; clear; close all;

%% (a). DFT Execution Time of Random Sequences with variable size.
Seq_Size = 2.^(4:10); % Various Sequence Sizes selected as powers of 2.
L = length(Seq_Size);
T = zeros(1,L);

for i=1:L
     Samples = Seq_Size(i);
     x = rand(1,Samples) + j*rand(1,Samples);
     X = zeros(1,Samples);

    tic;
    for k=0:Samples-1
         for n=0:Samples-1
              X(k+1) = X(k+1) + x(n+1)*exp(-j*2*pi*n*k/Samples);
         end
    end
    T(i) = toc;
end
    
figure('Name','Exercise 6.1.2. Direct DFT Evaluation');
plot(log2(Seq_Size),T,'r*-');
title('Execution Time vs Sequence Length');
xlabel('log_2(Sequence Length)');
ylabel('Execution Time (sec)');
axis tight;
grid on;

Contact us