Impact location detection from accelerometer data
Show older comments
I have accelerometer data coming from a accelerometer sensor which is mounted on top of handle of a cricket bat, I have played some shots some are missed and some hit, now I want to detect which shots are missed shots and which shots are hit shots. So how I can detect impact location or collide between cricket bat and ball. I guess there should be some algorithm or procedures by which we can get clue of impact location. Do matlab provide any script for it or how I can get help regarding this.
5 Comments
Dyuman Joshi
on 1 Mar 2024
How is the data stored? In which format?
How should the data be interpreted?
It would be better if you would share all the necessary details and information, which would aid us in providing suggestions/solutions accordingly.
Mathieu NOE
on 1 Mar 2024
you can probaly distinguish based on amplitude and duration
would of course be nice to hace access to the data
xubyr
on 1 Mar 2024
Mathieu NOE
on 4 Mar 2024
hello again
can you comment your graph and describes what you habe done to generate that data ? we needto make the correlation between the graph and the events
xubyr
on 8 Mar 2024
Answers (1)
Mathieu NOE
on 8 Mar 2024
Edited: Mathieu NOE
on 8 Mar 2024
hello
so this would be my suggestion
I hope my conclusion is not completely wrong !
At the end it seems I can clearly see 3 sharp and high amplitude peaks (above 5 g's ) corresponding to good hits; the other minor peaks are either missed hits or you shaking the baseball

code :
filename = "data1.csv";
data = importfile(filename);
% data = readtable('data1.csv') ; %
% data format :
% x,"y","z","timestamp"
% 0.10,"-1.69","9.85","14:58:30:267"
x = data.x;
y = data.y;
z = data.z;
timestamp = data.timestamp;
tmp = split(timestamp,':');
h = str2double(tmp(:,1)); % h column
m = str2double(tmp(:,2)); % m column
s = str2double(tmp(:,3)); % s column
ms = str2double(tmp(:,4)); % ms column
ts = h*3600 + m*60 + s + ms/1e3; % time in seconds
ts = ts - ts(1);
% plot(diff(ts)) ; % Nb the non constant sampling interval
% resample the data on a constant time interval time vector
tt = linspace(ts(1),ts(end),numel(ts));
x = interp1(ts,x,tt);
y = interp1(ts,y,tt);
z = interp1(ts,z,tt);
dt = mean(diff(tt));
Fs = 1/dt;
figure(1)
plot(tt,x,tt,y,tt,z);
legend('x','y','z')
% some high pass filtering to remove DC / low frequency signals
flow = 1;
[b,a] = butter(2,flow*2/Fs,'high');
xf = filtfilt(b,a,x);
yf = filtfilt(b,a,y);
zf = filtfilt(b,a,z);
figure(2)
plot(tt,yf,tt,zf);
legend('y','z')
figure(3)
% combine x,y,z signals into one rms signal
% see x direction contribution is neglectable , we can focus on y and z
% components only
rms_xyz = sqrt(xf.^2 + yf.^2 + zf.^2);
rms_yz = sqrt(yf.^2 + zf.^2);
plot(tt,rms_yz,tt,rms_xyz);
title('RMS (X) Y and Z acceleration');
xlabel('time (s)');
ylabel('amplitude (g)');
legend('rms(yz)','rms(xyz)')
3 Comments
Mathieu NOE
on 25 Mar 2024
hello
so have you solved your problem ?
xubyr
on 5 Apr 2024
Mathieu NOE
on 5 Apr 2024
hello again
do you have access to matlab ? if yes , and if you are new to it , I would suggest to look at some tutorials :
all the best
Categories
Find more on RESTful API in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!