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

clear
close

load wave_dat;
size(wave_dat)
nt=wave_dat(1,1);
dt=wave_dat(1,2);
amin=wave_dat(1,3)
amax=wave_dat(1,4)

if amax < -amin
  amax=-amin;
end
amax=1.2*amax;

t1=0.0
t2=dt*nt

for i=1:nt,
t(i)=wave_dat(i+1,1);
wave_x(i)=wave_dat(i+1,2);
wave_y(i)=wave_dat(i+1,3);
wave_z(i)=wave_dat(i+1,4);
end

subplot(3,1,1)
plot(t,wave_x)
axis([t1,t2,-amax,amax])
title('X')
ylabel('amplitude of X')

subplot(3,1,2)
plot(t,wave_y)
axis([t1,t2,-amax,amax])
title('Y')
ylabel('amplitude of Y')

subplot(3,1,3)
plot(t,wave_z)
axis([t1,t2,-amax,amax])
title('Z')
ylabel('amplitude of Z')

xlabel('time (sec)')

print wave.ps


