% A "m" file for Matlab. After making a "x_dat" file from "grfftm.f", you
% can plot waveforms using Matlab. A post script data is stored in the 
% "x.ps" file.

clear
close

load wave2_dat;
size(wave2_dat)
nob=wave2_dat(1,1)
nt=wave2_dat(1,2)
dt=wave2_dat(1,3)

load xyz_dat;
size(xyz_dat)
nt1=xyz_dat(1,1)
nob1=xyz_dat(1,2)

load x_dat;
load y_dat;
load z_dat;
load time_dat;
size(time_dat)
f=max(time_dat)
amaxx=max(x_dat)*2
amaxy=max(y_dat)*2
amaxz=max(z_dat)*2
afac=1.8
ax=amaxx/afac;
ay=amaxy/afac;
az=amaxz/afac;
bx=amaxx/2;
by=amaxy/2;
bz=amaxz/2;

subplot(1,3,1)
hold on
for i=1:nob,
  for j=1:nt,
    x(j)=x_dat(nt*(i-1)+j)+ax+amaxx*(i-1)/2;
    x1(j)=wave2_dat(nt*(i-1)+1+j,1)+ax+amaxx*(i-1)/2;
  end
  plot(time_dat,x1,'-',time_dat,x,'--')
end
hold off
title('NS')
set(gca, 'box','on')
axis([0 f 0 ax+bx+amaxx*(nob-1)/2])
ylabel('velocity')
xlabel('time (sec)')

subplot(1,3,2)
hold on
for i=1:nob,
  for j=1:nt,
    y(j)=y_dat(nt*(i-1)+j)+ay+amaxy*(i-1)/2;
    y1(j)=wave2_dat(nt*(i-1)+1+j,2)+ay+amaxy*(i-1)/2;
  end
  plot(time_dat,y1,'-',time_dat,y,'--')
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,
    z(j)=z_dat(nt*(i-1)+j)+az+amaxz*(i-1)/2;
    z1(j)=wave2_dat(nt*(i-1)+1+j,3)+az+amaxz*(i-1)/2;
  end
  plot(time_dat,z1,'-',time_dat,z,'--')
end
hold off
title('UD')
set(gca, 'box','on')
axis([0 f 0 az+bz+amaxz*(nob-1)/2])
xlabel('time (sec)')

print grfbxin2.ps


