clear
close

fig=figure('Units','inches','Position',[0.0 0.0 8.5 11.0]...
,'PaperUnits','inches','PaperPosition',[0.0 0.0 8.5 11.0]);

factor=0.3

load wavem_dat;
n=size(wavem_dat,1)-1
nob=wavem_dat(1,1)

amx=0.0;
for j=1:nob
  for i=1:n/nob,
    it=(i-1)*nob+j;
    t(i)=wavem_dat(it+1,1);
    x(i)=wavem_dat(it+1,2);
    y(i)=wavem_dat(it+1,3);
    z(i)=wavem_dat(it+1,4);
  end
  amax(1)=max(abs(x));
  amax(2)=max(abs(y));
  amax(3)=max(abs(z));
  a=max(amax);
  if a > amx
     amx=a;
  end
end
amx=amx*factor
tmx=max(t)

subplot(3,1,1)
hold on
ami=0.0;
for j=1:nob,
  for i=1:n/nob,
    it=(i-1)*nob+j;
    t(i)=wavem_dat(it+1,1);
    x(i)=wavem_dat(it+1,2)+amx*(j-1);
  end
  a=min(x);
  if a < ami,
    ami=a*1.5;
  end
  plot(t,x)
end
ama=max(x)*1.02;
axis([0 tmx ami ama])
title('Velocity X Component')
ylabel('Velocity_X (cm/s)')
xlabel('time (sec)')
set(gca, 'box','on')
hold off

subplot(3,1,2)
hold on
ami=0.0;
for j=1:nob,
  for i=1:n/nob,
    it=(i-1)*nob+j;
    t(i)=wavem_dat(it+1,1);
    y(i)=wavem_dat(it+1,3)+amx*(j-1);
  end
  a=min(y);
  if a < ami,
    ami=a*1.5;
  end
  plot(t,y)
end
ama=max(y)*1.02;
axis([0 tmx ami ama])
title('Velocity Y Component')
ylabel('Velocity_Y (cm/s)')
xlabel('time (sec)')
set(gca, 'box','on')
hold off

subplot(3,1,3)
hold on
ami=0.0;
for j=1:nob,
  for i=1:n/nob,
    it=(i-1)*nob+j;
    t(i)=wavem_dat(it+1,1);
    z(i)=wavem_dat(it+1,4)+amx*(j-1);
  end
  a=min(z);
  if a < ami,
    ami=a*1.5;
  end
  plot(t,z)
end
ama=max(z)*1.02;
axis([0 tmx ami ama])
title('Velocity Z Component')
ylabel('Velocity_Z (cm/s)')
xlabel('time (sec)')
set(gca, 'box','on')
hold off

print p.ps

