function expwrite(a,filename);
%EXPWRITE - write an Argus file from a structure given in input
%
%   This routine write an Argus file form a structure containing the fields:
%   x and y of the coordinates of the points.
%   The first argument is the structure containing the points coordinates 
%   and the second one the file to be write.
%
%   Usage:
%      expwrite(a,filename)
% 
%   Example:
%      expwrite(coordstruct,'domainoutline.exp')
%
%   See also EXPDOC, EXPREAD, EXPWRITEASVERTICES

fid=fopen(filename,'w');
for n=1:length(a),
   
   if ~isempty(a(n).name),
	   fprintf(fid,'%s%s\n','## Name:',a(n).name);
   else
	   fprintf(fid,'%s\n','## Name:');
   end
   
   fprintf(fid,'%s\n','## Icon:0');
   fprintf(fid,'%s\n','# Points Count  Value');
   fprintf(fid,'%i %f\n',[length(a(n).x) a(n).density]);
   fprintf(fid,'%s\n','# X pos Y pos');

   for i=1:length(a(n).x),
         fprintf(fid,'%f %f\n',[a(n).x(i) a(n).y(i)]);
   end  
   fprintf(fid,'\n','');
   
end
fclose(fid);
