%Lilla Lots + Kaffekoppen
g=9.82;
load kaffe_wdss -ascii
% indata : tid(s), höjd(m), ay, ax, az (m/s^2)
% x - radiell, z=vertikal, y=sidled
am_short=kaffe_wdss(201:1401,:);

tid=am_short(:,1)-am_short(1,1);
hojd =am_short(:,2);
alat =am_short(:,3)/g;
along =am_short(:,4)/g;
avert =am_short(:,5)/g+1; %trimmad!

atot=(along.^2+alat.^2+avert.^2).^0.5;

figure(1)
subplot (2,1,1)
plot(tid,avert,tid, atot) 
ylabel ('avert/g, atot/g, raw')
%axis([0 35 -2 5])
grid on

subplot(2,1,2)
plot(tid,hojd)
%axis([0 35 -5 25])
grid on
ylabel ('hojd (m)')

figure (2)
subplot(2,1,1)
plot(tid,along)
%axis([0 35 -2 2])
grid on
ylabel ('alongraw/g')

subplot(2,1,2)
plot(tid,alat)
%axis([0 35 -2 2])
grid on
ylabel ('alatraw/g')

figure (3)
N=length(alat)-4;
%alatsm=(alat(1:N-1) + 2*alat(2:N) + alat(3:N+1))/4;
%alongsm=(along(1:N-1) + 2*along(2:N) + along(3:N+1))/4;

alatsm=(alat(1:N-3) + alat(2:N-2) + alat(3:N-1)+alat(4:N) +alat(5:N+1) + alat(6:N+2) + alat(7:N+3))/7;
alongsm=(along(1:N-3) + along(2:N-2) + along(3:N-1)+along(4:N) +along(5:N+1) + along(6:N+2) + along(7:N+3))/7;
avertsm=(avert(1:N-3) + avert(2:N-2) + avert(3:N-1)+avert(4:N) +avert(5:N+1) + avert(6:N+2) + avert(7:N+3))/7;
%atotsm=(atot(1:N-3) + atot(2:N-2) + atot(3:N-1)+atot(4:N) +atot(5:N+1) + atot(6:N+2) + atot(7:N+3))/7;

atotsm=(alatsm.^2 + alongsm.^2).^0.5;

%alongsm=(along(1:N-1) + 1*along(2:N) + along(3:N+1))/3;
%alongsm=(along(1:N-1) + 1*along(2:N) + along(3:N+1))/3;


subplot(2,1,1)
plot(tid(1:N-3),alongsm)
%axis([0 35 -2 2])
grid on
%title('smooth, (1+2+1)/4')
title('smooth, (1+1+1)/3')
ylabel ('alongsm/g')

subplot(2,1,2)
plot(tid(1:N-3),alatsm)
%axis([0 35 -2 2])
grid on
ylabel ('alat/g')

figure (4)
subplot(3,1,1)
title('KAFFEKOPPEN')
plot(tid(1:N-3),alatsm,tid(1:N-3),alongsm)
ylabel ('radiell, sidled/g')
axis([0 60 -0.2 0.6])
grid on 
%title('KAFFEKOPPEN')
subplot(3,1,2)
plot(tid(1:N-3),alatsm,tid(1:N-3),alongsm)
ylabel ('radiell, sidled/g')
axis([15 35 -0.2 0.6])
grid on 
subplot(3,1,3)

plot(tid(1:N-3),alatsm,tid(1:N-3),alongsm,tid(1:N-3),atotsm)
ylabel ('total')
axis([0 60 0 0.6])
grid on 
