Remove gravity component from accelerometer data

88 次查看(过去 30 天)
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
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
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');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Objects 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by