%**************************************************************************
%This function outputs analysis comparison results to the data file.
%
%Input:
%dat_file, data file for results
%
%Zachary Wolf
%6/16/16

function [] = pid_comp_dat_comp(dat_file, gap, k_eff, pe_enter, pe_center, pe_exit, pe_cell)

%Convert to degrees
pe_enter = pe_enter * 180 / pi;
pe_center = pe_center * 180 / pi;
pe_exit = pe_exit * 180 / pi;
pe_cell = pe_cell * 180 / pi;

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

%Write the values to the data file
fprintf(fid, '\r\n\r\n');
fprintf(fid, '          Compare Analysis Results          \r\n');
fprintf(fid, '\r\n');
fprintf(fid, ' Nom Gap        Keff      Phase Err Enter  Phase Err Center  Phase Err exit  Phase Err Cell\r\n');
fprintf(fid, '   (mm)                        (deg)            (deg)             (deg)           (deg)    \r\n');
fprintf(fid, '-----------  -----------  ---------------  ----------------  --------------  --------------\r\n');
for ii = 1 : length(gap)
    fprintf(fid, '%11.3f  11.6f  15.3f  15.3f  15.3f  15.3f\r\n', gap(ii), k_eff(ii), pe_enter(ii), pe_center(ii), pe_exit(ii), pe_cell(ii));
end
%Close the file
fclose(fid);

%Done
