function [utmx,utmy]=LL2utm(lon,lat);

% Syntax
% [utmx,utmy]=LL2utm(lon,lat);
% keyboard
% Get mean longitude and latitude
idx=find(~isnan(lon)); mlon=mean(lon(idx)); 
idx=find(~isnan(lat)); mlat=mean(lat(idx));
% Obtain the UTM zone:
z1 = utmzone([mlat,mlon]);
fprintf('Using UTM zone %s.\n',z1);
% Obtain the suggested ellipsoid vector and name for this zone:
% [ellipsoid,estr] = utmgeoid(z1);
% Set up the UTM coordinate system based on this information:
utmstruct = defaultm('utm'); 
utmstruct.zone = z1; 
utmstruct.geoid = wgs84Ellipsoid; 
utmstruct = defaultm(utmstruct);
% calculate the grid coordinates
[utmx,utmy] = mfwdtran(utmstruct,lat,lon);
