The data are not regularly-sampled, so in order to do any meaningful signal processing on them, they need to be resampled to a consistent sampling interval. I did this with the resample function, and since the sampling frequency of the original data was about 73 Hz, I chose a sampling frequency of 70 Hz. Choose whatever works best, however it would be better to go with a lower than a higher resampling frequency, since this avoids creating data where none previously existed.
The noise ais actually broadband, and the best way to deal with broadband noise is to use the Savitzky-Golay filter (sgolayfilt function) or wavelet denoising. I will help you with sgolayfilt if that is the direction you want to go. I use a frequency selective filter here to start with.
% opts = weboptions('ContentType','text');
% W = webread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1038845/Tracking.m', opts)
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1038850/Diagonal66cm.xlsx', 'VariableNamingRule','preserve')
tstr = {'X','Y','Z'};
figure
for k = 1:3
subplot(3,1,k)
plot(T1.Timestamps, T1{:,k})
grid
title(tstr{k})
xlim([min(T1.Timestamps) max(T1.Timestamps)])
end
xlabel('Time')
sgtitle('Original Accelerometer Data')
fse = 1/mean(diff(T1.Timestamps))
Fs = 70;
[Acr,tr] = resample(T1{:,1:3}, T1.Timestamps, Fs)
figure
for k = 1:3
subplot(3,1,k)
plot(tr, Acr(:,k))
grid
title(tstr{k})
xlim([min(tr) max(tr)])
end
xlabel('Time')
sgtitle('Resampled Accelerometer Data')
Fn = Fs/2;
L = numel(tr);
NFFT = 2^nextpow2(L); % For Efficiency
FT_Acr = fft(Acr-mean(Acr),NFFT)/L; % Subtract 'mean' TO See Other Peaks
Fv = linspace(0, 1, NFFT/2+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
for k = 1:3
subplot(3,1,k)
plot(Fv, abs(FT_Acr(Iv,k))*2)
grid
title(tstr{k})
xlim([min(Fv) max(Fv)])
end
xlabel('Frequency')
ylabel('Amplitude')
sgtitle('Accelerometer: Fourier Transform')
xlim([min(Fv) max(Fv)])
% return
Wp = [0.00005 12.5]/Fn; % Passband Frequency (Normalised)
Ws = [0.9 1.10].*Wp; % Stopband Frequency (Normalised)
Rp = 1; % Passband Ripple
Rs = 60; % Passband Ripple (Attenuation)
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Elliptic Order Calculation
[z,p,k] = ellip(n,Rp,Rs,Wp); % Elliptic Filter Design: Zero-Pole-Gain
[sos,g] = zp2sos(z,p,k); % Second-Order Section For Stability
figure
freqz(sos, 2^16, Fs) % Filter Bode Plot
Acr_filt = filtfilt(sos, g, Acr); % Filter Signal
tstr = {'X','Y','Z'};
figure
for k = 1:3
subplot(3,1,k)
plot(tr, Acr_filt(:,1))
grid
title(tstr{k})
xlim([min(tr) max(tr)])
end
xlabel('Time')
sgtitle('Filtered Accelerometer Data')
.