g=9.82;
load am_wdss -ascii
% indata : tid(s), höjd(m), ay, ax, az (m/s^2)

am_short=am_wdss(581:1301,:);

tid=am_short(:,1)-am_short(1,1);
hojd =am_short(:,2);
alat =am_short(:,3)/g;
avert =am_short(:,4)/g;
along =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, alat,tid, along,tid, atot) 
plot(tid,avert,tid, atot) 
%ylabel ('avert/g, atot/g')
ylabel ('a/g')
axis([0 35 -2 5])
grid on

subplot(2,1,2)
plot(tid,hojd)
axis([0 35 -5 25])
grid on
ylabel ('hojd (m)')
xlabel ('tid (s)')
figure (2)
subplot(2,1,1)
plot(tid,along)
axis([0 35 -2 2])
grid on
ylabel ('along/g')

subplot(2,1,2)
plot(tid,alat)
axis([0 35 -2 2])
grid on
ylabel ('alat/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;

%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 ('alatsm/g')

figure (5)
subplot(1,1,1)
plot(tid(2:72),alongsm(2:72)+1)
grid on
ylabel ('alatsm/g')
