Filtering
trans = fft(throw_az)
stem(trans)
plot(throw_az)
n=[-20:20];
wc=pi/300; %cut-off frequency (chosen arbitrarily to make data look clean)
h=wc/pi*sinc(wc*n/pi);
filt_az=conv(throw_az,h); %filtered z-acceleration
filt_az=filt_az(1:length(throw_az),1)
plot(throw_az)
plot(filt_az)
Visualization
clf
throw_ax = (ax(1178:1286)-mean(ax(1:100)))*9.8;
throw_ay = (ay(1178:1286)-mean(ay(1:100)))*9.8;
throw_az = (az(1178:1286)-mean(az(1:100)))*9.8
throw_t = t(1178:1286)/1000;
throw_gx = gx(1178:1286)-mean(gx(1:100));
throw_gy = gy(1178:1286)-mean(gy(1:100));
throw_gz = gz(1178:1286)-mean(gz(1:100));
clf
theta = cumtrapz(throw_t,throw_gz)'/16.4;
plot(throw_t,theta)
a_room = zeros(3, 109);
for i=1:length(throw_gx)
R = [cos(theta(:,i)) sin(theta(:,i)) 0; -sin(theta(:,i)) cos(theta(:,i)) 0; 0 0 1];
a_room(:, i) = R*[throw_ax(i,:); throw_ay(i,:); filt_az(i,:)];
end
a_room = a_room'
vx = cumtrapz(throw_t, a_room(:,1));
vy = cumtrapz(throw_t, a_room(:,2));
vz = cumtrapz(throw_t, a_room(:,3));
clf
sx = cumtrapz(throw_t, vx);
sy = cumtrapz(throw_t, vy);
sz = cumtrapz(throw_t, vz);
axis equal
for i=1:length(throw_t)
scatter3(sx(i,:), sy(i,:), -sz(i,:))
hold on
axis([0 .2 0 .2 0 .2])
end