clear all
close all

data=load('data.txt');
t=data(:,1);
y=data(:,2);
y=y-mean(y);
del=diff(t);
Fs=1/mean(del);
L=length(y);
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
Y(1)=Y(1)/2;
f = Fs/2*linspace(0,1,NFFT/2+1);

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

subplot(1,2,2);
plot(t,y);
xlabel('Time (s)');
title('Angle Waveform')
xlim([0,20]);
axis square
ylabel('Angle (deg)');