raw_data = load('glycerine#1_1_5214.txt');
M = length(raw_data(:,1));

[mx max_index] = max(raw_data(:,2));
buffer = 5;
data = raw_data((max_index+buffer):M,:);
N = length(data(:,1));

% Period of sample
T = data(2,1) - data(1,1);

subplot(211);
plot(1000*data(:,1),data(:,2));
xlabel('Time (in ms)');
ylabel('FID (arb. scale)');

xlim([1000*data(1,1) 1000*data(N,1)]);
scale = 1:N;
scale = scale - N/2;
f = 1/T*scale/N
F = fft(data(:,2),N);
subplot(212);
plot(f/1000,fftshift(log(abs(F)/N)));
xlabel('Frequency in kHz');
ylabel('Power spectrum');