% printfft.m  m-file to print fft amplitudes
% of a signal

  function printfft(wavetype,f1,freq,Ampl,Ay,Gy,Amp,phase,off,Nf,filename)

an=real(Ay(1:10))';
bn=imag(Ay(1:10))';
An=Ampl(1:10)';
fr=freq(1:10)';
disp(['   '])

An_an_bn=[fr An an bn];
variance=sum(Gy(2:Nf)*f1);

 fprintf(1,['\nWavetype:         ' wavetype '\n']);
 fprintf(1,'Wave Amplitude:   %.3f \n',Amp);
 fprintf(1,'Wave Offset:      %.3f \n',off);
 fprintf(1,'Wave Phase:       %.3f \n',phase);
 fprintf(1,'Wave Variance:    %.3f \n\n',variance);
 fprintf(1,'Freq      Amp          an           bn \n');
 fprintf(1,'%.2f     %.4f      %.4f      %.4f \n',An_an_bn');

disp(' ');
fileout=input('Do you want to save wave statistics to your output file (y or n)? ','s');
if fileout(1) =='y'
 fid=fopen(filename,'a');
 fprintf(fid,['\n\nWavetype:         ' wavetype '\n']);
 fprintf(fid,'Wave Amplitude:   %.3f \n',Amp);
 fprintf(fid,'Wave Offset:      %.3f \n',off);
 fprintf(fid,'Wave Phase:       %.3f \n',phase);
 fprintf(fid,'Wave Variance:    %.3f \n\n',variance);
 fprintf(fid,'Freq      Amp          an           bn \n');
 fprintf(fid,'%.2f     %.4f      %.4f      %.4f \n',An_an_bn');
 fclose(fid);
 disp(['Data appended to file ' filename '.']);
 disp(' ')
end % if fileout

return;




