function density=meshdensitygen(infile,nel);
%MESHDENSITYGEN -  ???
%
%   Usage:
%      struct=meshdensitygen(infile,nel);

density=expread(infile,1);

for i=1:length(density), 
	
	%Find density by figuring out largest distance between 
	%two points of the density profile, and divide by the number 
	%of elements desired for this profile.
	maxdist=maxdistprofile(density(i).x,density(i).y);
	density(i).density=round(maxdist/sqrt(nel));
end


function maxdist=maxdistprofile(x,y);

for i=1:length(x),
dist=sqrt((x-x(i)).^2+(y-y(i)).^2);
pos=find(dist==max(dist));
maxdist=dist(pos);
end
