%**************************************************************************
%This function outputs analysis comparison results to the data file.
%
%Input:
%dat_file, data file for results
%gap, undulator gap (m)
%k_eff, undulator K value
%
%Zachary Wolf
%6/16/16

function [] = pid_fit_dat_k(dat_file, gap, k_eff)

%Convert
gap = gap * 1000;

%Open the data file
fid = fopen(dat_file, 'a');

%Write the values to the data file
fprintf(fid, '\r\n\r\n');
fprintf(fid, 'Measured Gap And K Values\r\n');
fprintf(fid, '\r\n');
fprintf(fid, '\r\n');
fprintf(fid, ' Meas Gap       Keff    \r\n');
fprintf(fid, '   (mm)                 \r\n');
fprintf(fid, '-----------  -----------\r\n');
for ii = 1 : length(gap)
    fprintf(fid, '%11.3f  %11.6f\r\n', gap(ii), k_eff(ii));
end
%Close the file
fclose(fid);

%Done
