function [ FFTfreq, FFTdata ] = FourierTransformRabi( time, data )
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here

%finding parameters
d = 1000*time(end); %duration of measurement, e.g. 8000 ns
L = length(time); %number of data points, e.g. 361
T = d*10^-9/(L);             % Duration of measurement per point = "sample time" [s]
Fs = 1/T;                     % Sampling Frequency [Hz]

%substracting mean value
data = data - mean(data);
lengthFFT=1*L;

FFT = abs(fft(data,lengthFFT));
FFTdata = FFT(1:ceil(lengthFFT/2)); %discard half of the points (as FTT mirrors the spectrum)

FFTfreq = zeros(1,ceil(lengthFFT/2));

FFTfreq(2:floor(lengthFFT/2)+1) = Fs/10^6*(1:floor(lengthFFT/2))/lengthFFT; %creates the frequency axis in units of [MHz]
% FFTfreq(1:floor(lengthFFT/2)) = Fs/10^6*(1:floor(lengthFFT/2))/lengthFFT; 
end

