%function str = lon2str(deg,n)
function str = lon2str(deg,n)

if nargin == 1, n = 6; end
fdeg = fix(deg);
dd = int2str(abs(fdeg));
form = ['%.' int2str(n) 'f'];
mm = sprintf(form,abs(deg-fdeg)*60);

if deg >= 0, hemi = 'E';
else hemi = 'W'; end

if abs(deg) < 100, zero = '0';
else zero = []; end

str = [hemi zero dd ' ' mm];
