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.

ex633.m
% Exercise 6.3.3. Computational Complexity of the FFT.
clear; clc;

powers = 4:11;
lengths = 2.^powers;
timeFFT = zeros(size(powers));
timeDFT = zeros(size(powers));

for i=1:length(lengths)
% Compute its N-point DFT:
    Samples = lengths(i);
    x = rand(1,Samples);
      
    tic
    X = my_DFT(x); 
    DFTtime(i) = toc;
 
    tic
    X2 = fft(x);
    FFTtime(i) = toc;
end

 %% Plot the results.
figure('Name','Exercise 6.3.3. Computational Complexity of the FFT');
plot(log2(lengths),DFTtime,'b*-');
hold on;
plot(log2(lengths),FFTtime,'r*-');
grid on;
ylabel('Execution Time (sec)');
xlabel('Sequence Length in Log_2 Scale: log_2(length(x))');
title('DFT (blue) vs FFT (red) Execution Time)');

Contact us