function dist = coordWriteFile(names,coord,residue,filename)
%
%  $BEGIN
%  $HEADER coordWriteFile
%
%  Write the coordinates and atom names in a simple
%  file for output.
%
%  $HEADER REFERENCE
%  Protein Data Bank Contents Guide:
%  http://www.rcsb.org/pdb
%
%  $HEADER PROGRAMMER
%  John W. Craft, Jr.
%  University of Houston, (2005)
%
%  $HEADER VERSION
%  1.0.0
%
%  Example
%  error = coordWriteFile(name,coord,'SEP','my_new_file.pdb')
%
%  See Also pdbWriteFile pdbReadFile
%  
%  $END
%

[m,n] = size(coord);

FID = fopen(filename,'w');


fprintf(FID,'REMARK    4  MATLAB generated PDB file University of Houston / Craft\n');

for i = 1:m

fprintf(FID,'%8.3f',coord(i,1) );     % Orthogonal coordinates for X
fprintf(FID,'%8.3f',coord(i,2) );     % Orthogonal coordinates for Y
fprintf(FID,'%8.3f',coord(i,3) );     % Orthogonal coordinates for Z
fprintf(FID,'\n');

end

fprintf(FID,'END');

fclose(FID);

return

