clc
data = xlsread('Reading 5(10000).xlsx') ;
t = data (1:1024,1);
s = data (1:1024,4);
L = numel(t);
Ts = mean(diff(t));
Fs = 1/Ts;
Fn = Fs/2;
FTs = fft(s)/L;
Fv = linspace(0,1, fix(L/2)+1)*Fn;
Iv = 1:numel(Fv);
IV = Iv-mean(Iv);
FTsiga = double(abs(FTs(Iv))*2);
S_smth = sgolayfilt(FTsiga,20,501);
h = figure(1);
subplot(4, 1, 1);
plot(t,s);
set(gca,'xlim',[1 51.2]);
grid;
title ({'Graph 5','Acceleration vs time'});
xlabel('time(s)');
ylabel('Acceleration (m/s^2)');
subplot(4, 1, 2);
plot(Fv, abs(FTs(Iv))*2,'red');
grid
title ('Fast fourier transform');
xlabel('Frequency (Hz)');
ylabel ('Amplitude (m)');
subplot(4, 1, 3);
Y = fft(s-mean(s));
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
plot(Fv,P1,'Green');
title ('Fast Fourier Transform - "DC removed"');
xlabel('Frequency (Hz)');
ylabel ('Amplitude (m)');
subplot(4,1,4);
plot (Fv,S_smth,'-k');
title ('Fast Fourier Transform - "Filtered"');
xlabel('Frequency (kHz)');
ylabel ('Amplitude (m)');