# Remove gravity component from accelerometer data

조회 수: 101(최근 30일)
Francesco Lucarelli 2021년 7월 23일
댓글: Mathieu NOE 2021년 7월 23일
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!!

댓글을 달려면 로그인하십시오.

### 채택된 답변

Mathieu NOE 2021년 7월 23일
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
% 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표시숨기기 이전 댓글 수: 1
Mathieu NOE 2021년 7월 23일
you're welcome !

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!

Translated by