% 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 mat0_dat;
nob=mat0_dat(1,1);
nt=mat0_dat(1,2);
dt=mat0_dat(1,3);

load matx_dat;
amax=max(matx_dat);
amin=min(matx_dat);
if amin < -amax
   amax=-amin;
end

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

a=amax;
aa=amax/4;
hold on
for i=1:nob,
  for j=1:nt,
    wave_d(j)=matx_dat(nt*(i-1)+j)+a+aa*(i-1);
  end
  plot(t,wave_d)
end
hold off

title('NS')
set(gca, 'box','on')
axis([0 f 0 2*a+aa*(nob-1)])
ylabel('amplitude of NS')
xlabel('time (sec)')

print wavex.ps


