% A "m" file for Matlab. After making a "amp_dat" file from "grfft.f", you
% can plot ampforms using Matlab. A post script data is stored in the 
% "amp.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]);



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

for i=1:nt,
f(i)=amp_dat(i,1)/6.2831853;
xr=amp_dat(i,2);
xi=amp_dat(i,3);
yr=amp_dat(i,4);
yi=amp_dat(i,5);
zr=amp_dat(i,6);
zi=amp_dat(i,7);
x(i)=sqrt(xr*xr+xi*xi);
y(i)=sqrt(yr*yr+yi*yi);
z(i)=sqrt(zr*zr+zi*zi);
end
xmax=max(x);ymax=max(y);zmax=max(z);

load amp1_dat;
size(amp1_dat)
nt1=size(amp1_dat,1);

for i=1:nt1,
f1(i)=amp1_dat(i,1)/6.2831853;
xr=amp1_dat(i,2);
xi=amp1_dat(i,3);
yr=amp1_dat(i,4);
yi=amp1_dat(i,5);
zr=amp1_dat(i,6);
zi=amp1_dat(i,7);
x1(i)=sqrt(xr*xr+xi*xi);
y1(i)=sqrt(yr*yr+yi*yi);
z1(i)=sqrt(zr*zr+zi*zi);
end
xmax1=max(x1);ymax1=max(y1);zmax1=max(z1);

subplot(3,1,1)
plot(f,x,'-',f1,x1,'--')
title(['NS (max1=',num2str(xmax),', max2=',num2str(xmax1),')'])
ylabel('Fourier Amplitude')
%axis([0 dur -amax amax])

subplot(3,1,2)
plot(f,y,'-',f1,y1,'--')
title(['EW (max1=',num2str(ymax),', max2=',num2str(ymax1),')'])
ylabel('Fourier Amplitude')
%axis([0 dur -amax amax])

subplot(3,1,3)
plot(f,z,'-',f1,z1,'--')
title(['UD (max1=',num2str(zmax),', max2=',num2str(zmax1),')'])
ylabel('Fourier Amplitude')
xlabel('Frequency (Hz)')
%axis([0 dur -amax amax])

print amp.ps
