%clear
close

fac=1.0
load wave_d2;
size(wave_d2)
nob=wave_d2(1,1)
nt=wave_d2(1,2)
dt=wave_d2(1,3)

for j=1:nt,
  t(j)=dt*(j-1);
end
f=max(t)


amaxx=0.0;
amaxy=0.0;
amaxz=0.0;
for i=1:nob,
  for j=1:nt,
    axx=abs(wave_d2(nt*(i-1)+1+j,1));
    if axx > amaxx amaxx=axx; end
    ayy=abs(wave_d2(nt*(i-1)+1+j,2));
    if ayy > amaxy amaxy=ayy; end
    azz=abs(wave_d2(nt*(i-1)+1+j,2));
    if azz > amaxz amaxz=azz; end
  end
end
amaxx=amaxx*fac
amaxy=amaxy*fac
amaxz=amaxz*fac

ax=amaxx/fac
bx=amaxx/fac
ay=amaxy/fac
by=amaxy/fac
az=amaxz/fac
bz=amaxz/fac

subplot(1,3,1)
hold on
for i=1:nob,
  for j=1:nt,
    wx(j)=wave_d2(nt*(i-1)+j+1,1)+ax+amaxx*(nob-i)/2;
  end
  plot(t,wx)
end
hold off
title('NS')
set(gca, 'box','on')
axis([0 f 0 ax+bx+amaxx*(nob-1)/2])
ylabel('Velocity (cm/s)')
xlabel('time (sec)')

subplot(1,3,2)
hold on
for i=1:nob,
  for j=1:nt,
    wy(j)=wave_d2(nt*(i-1)+j+1,2)+ay+amaxy*(nob-i)/2;
  end
  plot(t,wy)
end
hold off
title('EW')
set(gca, 'box','on')
axis([0 f 0 ay+by+amaxy*(nob-1)/2])
xlabel('time (sec)')

subplot(1,3,3)
hold on
for i=1:nob,
  for j=1:nt,
    wz(j)=wave_d2(nt*(i-1)+j+1,3)+az+amaxz*(nob-i)/2;
  end
  plot(t,wz)
end
hold off
title('UD')
set(gca, 'box','on')
axis([0 f 0 az+bz+amaxz*(nob-1)/2])
xlabel('time (sec)')
