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.

my_CTFT(x,dt,freq_type)
```function [freq X] = my_CTFT(x,dt,freq_type)
% Continuous Time Fourier Transform Approximation.
%
% Inputs:
% x  : the "analog" signal
% dt : the sampling interval in seconds for the simulated analog signal xa
% freq_type: a string containing the selected type of frequency. i.e. 'Hz' or 'rad/sec'.
%
% Outputs:
% X : vector containing the "continuous FT" of "analog" signal " x(t).
% freq: vector containing the "analog" frequency values where the CTFT was computed.
L = length(x);
Nfft = 2^(nextpow2(L)+2); % Choose the (nearest Power + 2) of 2
X = fftshift(fft(x,2*Nfft+1));
range = -Nfft:Nfft;

% sampling rate
ff = range/(2*Nfft+1)/dt; % frequencies in Hz
Omega = 2*pi*ff;  % frequencies in rad/sec

if strcmp(freq_type,'Hz')
freq = ff;
% plot(ff,abs(X),'r')
% xlabel('Analog Frequency f (Hz)');
freq = Omega;
% plot(Omega,abs(X),'r')