Remove gravity component from accelerometer data

96 visualizaciones (últimos 30 días)
Francesco Lucarelli
Francesco Lucarelli el 23 de Jul. de 2021
Comentada: Mathieu NOE el 23 de Jul. de 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!!

Respuesta aceptada

Mathieu NOE
Mathieu NOE el 23 de Jul. de 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 comentarios
Francesco Lucarelli
Francesco Lucarelli el 23 de Jul. de 2021
Thank a lot @Mathieu NOE
Much appriciated !!
Mathieu NOE
Mathieu NOE el 23 de Jul. de 2021
you're welcome !

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Objects en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by