%**************************************************************************
%This function writes to a text file Bx, By, and Bz vs z.
%
%Input:
%dat_file, data file for results
%z, position along the undulator (m)
%bx, x-component of the field (T)
%by, y-component of the field (T)
%bz, z-component of the field (T)
%
%Zachary Wolf
%6/20/13

function gen_dat_zbxyz(dat_file, z, bx, by, bz)

%Write the results to the data file
fid = fopen(dat_file, 'a');
fprintf(fid, '\r\n');
fprintf(fid, 'Bx, By, and Bz vs z:\r\n');
fprintf(fid, '     Z           Bx           By           Bz     \r\n');
fprintf(fid, '    (m)          (T)          (T)          (T)    \r\n');
fprintf(fid, '-----------  -----------  -----------  -----------\r\n');
fprintf(fid, '%11.6f  %11.6f  %11.6f  %11.6f\r\n', [z; bx; by; bz]);
fclose(fid);

%Done
