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.

my_DHT2(x,time_ind)
function X = my_DHT2(x,time_ind)
% This function calculates the Discrete Hartley Transform of a real
% sequence. In addition to the input signal x[n], this function takes 
% as an input the time indices as well. 
% Attention: length(x) must be odd for this to work properly.
% Note that time indices are common to frequency indices for the DHT.
N = length(x);
freq_ind = time_ind;
Half_Time_Size = (time_ind(end)-time_ind(1))/2; 
Half_Freq_Size = Half_Time_Size;

X = zeros(1,N);

for k=time_ind(1):time_ind(end)
     for n=freq_ind(1):freq_ind(end)
          X(k+Half_Freq_Size+1) = X(k+Half_Freq_Size+1) + ...
                                                      x(n+Half_Time_Size+1)*(cos(2*pi*n*k/N) + sin(2*pi*n*k/N));
    end
end

Contact us