% 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

%fig=figure('Units','centimeters','Position',[0.0 0.0 21.0 29.5]...
%,'PaperUnits','centimeters','PaperPosition',[0.0 0.0 21.0 29.5]);

fig=figure('Units','centimeters','Position',[0.0 0.0 21.0 26.0]...
,'PaperUnits','centimeters','PaperPosition',[0.0 0.0 21.0 26.0]);


dur=15
amax=200

load wave_dat;
size(wave_dat)
nt=size(wave_dat,1);

for i=1:nt,
t(i)=wave_dat(i,1);
x(i)=wave_dat(i,2)-wave_dat(1,2);
y(i)=wave_dat(i,3)-wave_dat(1,3);
z(i)=wave_dat(i,4)-wave_dat(1,4);
end

load green1_vel;
wave_out=green1_vel;
nt1=size(wave_out,1);

for i=1:nt1,
t1(i)=wave_out(i,1);
x1(i)=wave_out(i,2)-wave_out(1,2);
y1(i)=wave_out(i,3)-wave_out(1,3);
z1(i)=wave_out(i,4)-wave_out(1,4);
end
xmin=min(x1);
xmax=max(x1);
ymin=min(y1);
ymax=max(y1);
zmin=min(z1);
zmax=max(z1);

subplot(3,1,1)
plot(t,x,'-',t1,x1,'--')
title(['NS (max=',num2str(xmax),', min=',num2str(xmin),')'])
%title(['Radial (max=',num2str(xmax),', min=',num2str(xmin),')'])
ylabel('Velocity (cm/s)')
%axis([0 dur -amax amax])

subplot(3,1,2)
plot(t,y,'-',t1,y1,'--')
title(['EW (max=',num2str(ymax),', min=',num2str(ymin),')'])
%title(['Transverse (max=',num2str(ymax),', min=',num2str(ymin),')'])
ylabel('Velocity (cm/s)')
%axis([0 dur -amax amax])

subplot(3,1,3)
plot(t,z,'-',t1,z1,'--')
title(['UD (max=',num2str(zmax),', min=',num2str(zmin),')'])
ylabel('Velocity (cm/s)')
xlabel('time (sec)')
%axis([0 dur -amax amax])

print wave.ps
