function X = ctft(s, t, f)
% X = CTFT(S, T, W)
% Performs Continuous-Time Fourier Transform on signal s.
%
% Input     Size     Description
% --------------------------------------------
% s      : [1 x N] - the input signal
% t      : [1 x N] - the time vector (our time axis)
% f      : [1 x L] - the frequency vector in Hz
%
% Input     Size     Description
% --------------------------------------------
% X      : [1 x L] - the Continuous Time F.T.
% 
% Usage: [s, fs] = wavread('sample.wav');
%        t = 0:1/fs:length(seg)/fs - 1/fs;
%        f = [1:1:fs/2];
%        X = ctft(seg, t, f);
%
% See also: fft, ifft
%
% @ G.P. Kafentzis, CSD, SigProcLab, UoC, 2008.

M = exp(-1i*t'*2*pi*f);       % Fourier Matrix
dt = t(2)-t(1);
X = dt*s*M;   % Fourier Transform

figure; 
subplot(2,1,1); plot(f, abs(X), 'LineWidth', 2); ylabel('Magnitude');
title('Magnitude of Fourier Transform - |X(f)|'); xlabel('Frequency in Hz'); grid;
subplot(2,1,2); plot(f, angle(X), 'LineWidth', 2); ylabel('Radians');
title('Phase of Fourier Transform - \angle X(f)'); xlabel('Frequency in Hz'); grid;