Remove gravity component from accelerometer data

89 vues (au cours des 30 derniers jours)
Francesco Lucarelli
Francesco Lucarelli le 23 Juil 2021
Commenté : Mathieu NOE le 23 Juil 2021
Hi all,
could you advice me a method to remove the gravity component from my 3-axis accelerometer data?
Thank a lot for your help and time, much appreciated!
I've shared also my x y and z. thanks a lot!!

Réponse acceptée

Mathieu NOE
Mathieu NOE le 23 Juil 2021
hello Francesco
the simplest method is to simply remove the mean value of your signal.
another approach is to use a high pass filter, this can also be useful if you want to remove very low frequency drifts or motion effects .
tested on you x data , you can easily copy paste on y and z data;
plot :
code :
clc
clearvars
load('x.mat');
% load('y.mat');
% load('z.mat');
% Time
dt = 1e-3; % Length of each time step
samples = length(x);
t_ac = (0:samples-1)'*dt;
fs = 1/dt; % Frequency [Hz] or sampling rate
% acc = x(:)*9.81; % Add gravity factor (assumes data in g)
acc = x(:); % No gravity factor (assumes data in m/s²)
% remove "gravity" acceleration
% method 1 : remove mean value
acc_ref = mean(acc);
acc2 = acc - acc_ref; % ??
% method 2 : high pass filtering
N = 2;
fc = 1; % Hz
[B,A] = butter(N,2*fc/fs,'high');
acc3 = filter(B,A,acc);
figure(1)
plot(t_ac,acc,t_ac,acc2,t_ac,acc3);
title('acceleration (unit ?)');
xlabel('Time (s)')
ylabel('Amplitude (unit ?)')
legend('raw','mean removed','high pass filtered');
  2 commentaires
Francesco Lucarelli
Francesco Lucarelli le 23 Juil 2021
Thank a lot @Mathieu NOE
Much appriciated !!
Mathieu NOE
Mathieu NOE le 23 Juil 2021
you're welcome !

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Objects dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by