MATLAB: Continuous Time Fourier Transform of a signal matrix

fast fourier transform of continuous time signal

I have a matrix of 100 rows and 2 columns. Column 1 consists of time signal at frequency 50Hz (0.02 0.04 0.06…) column 2 is signal whose fft is to be determined. I would like to have a function that determines the Fourier transform of the signal at the frequency determined by the 1st column of the matrix.

Best Answer

If the first column of your matrix is just the time vector with increments of 0.02 seconds, then just take the Fourier transform of the 2nd column
Let X be your matrix
xdft = fft(X(:,2));
If the signal is real-valued, you only need 1/2 the DFT to examine the amplitude spectrum.
The frequency vector can be formed as follows:
freq = 0:50/100:25;
For example:
t = 0:0.02:(100*0.02)-0.02;
x = cos(2*pi*10*t)+randn(size(t));
X(:,1) = t';
X(:,2) = x';
% Now X is your matrix
xdft = fft(X(:,2));
xdft = xdft(1:length(xdft)/2+1);
freq = 0:50/100:25;
plot(freq,abs(xdft))
xlabel('Hz'); ylabel('Magnitude')