2
votes

I have a simple problem but since I have not used MATLAB Fourier Transform tools I need some help. I have a plot obtained from n excel file. The plot is in time domain. Time range for the plot is 0 to 50 ps. And I have data for the y component of the plot every 0.5 fs. Basically the plot contains 100000 data printed every 0.5fs. Now I want to get the Fourier transform of this plot. What should i do? The following is a simple format for my excel file that includes the data I needed to have the time-domain plot.

0       116.0080214
0.0005  116.051128
0.001   116.0939229
0.0015  116.1362197
0.002   116.1776665
0.0025  116.2178118
0.003   116.256182
.
.
.
.
50.0    123.000

The first column is time in ps. Thank you so much in advance for you helps. Best, HRJ

1
you can use the fft() function. Also if you have it there is a Digital Signals Processing toolbox that comes with a nice psd functionwillpower2727

1 Answers

5
votes

I have adapted this page for the solution.

    Fs = 100000/50;               % Sampling frequency (in 1/ps)
    T = 1/Fs;                     % Sample time (in ps)
    L = 100000;                   % Length of signal
    t = (0:L-1)*T;                % Time vector; your first column should replace this

    % Sum of a 50 1/ps sinusoid and a 120 1/ps sinusoid
    % Your second column would replace y 
    x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t); 
    y = x + 2*randn(size(t));     % Sinusoids plus noise

    NFFT = 2^nextpow2(L);         % Next power of 2 from length of y
    Y = fft(y,NFFT)/L;
    f = Fs/2*linspace(0,1,NFFT/2+1);

    close all
    subplot(2,1,1)
    % Plot your original signal
    plot(Fs*t(1:100),y(1:100))
    title('Signal Corrupted with Noise')
    xlabel('time (fs)')

    % Plot single-sided amplitude spectrum.
    subplot(2,1,2)
    plot(f,2*abs(Y(1:NFFT/2+1))) 
    title('Single-Sided Amplitude Spectrum of y(t)')
    xlabel('Frequency (1/ps)')
    ylabel('|Y(f)|')

Output of the FFT