Home > atmlab > geodetic > geographic_mean.m

geographic_mean

PURPOSE ^

Calculate mean position for set of coordinates

SYNOPSIS ^

function [mean_lat, mean_lon] = geographic_mean(lat, lon)

DESCRIPTION ^

 Calculate mean position for set of coordinates

 For each row of lat/lon, calculate mean position.

 TODO: consider altitude.  Currently takes fixed Earth radius.  Not very
 precise, but good enough for many applications.

 FORMAT

   [mean_lat, mean_lon] = geometric_mean(lat, lon)

 IN

   lat    Matrix of latitudes (degrees)
   lon    Matrix of longitudes (degrees), must have same size as lat

 OUT

   mean_lat    Mean vector of latitudes (degrees) for each row of lats
   mean_lon    Mean vector of longitudes (degrees) for each row of lons

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

geographic_mean.m

SOURCE CODE ^

0001 function [mean_lat, mean_lon] = geographic_mean(lat, lon)
0002 
0003 % Calculate mean position for set of coordinates
0004 %
0005 % For each row of lat/lon, calculate mean position.
0006 %
0007 % TODO: consider altitude.  Currently takes fixed Earth radius.  Not very
0008 % precise, but good enough for many applications.
0009 %
0010 % FORMAT
0011 %
0012 %   [mean_lat, mean_lon] = geometric_mean(lat, lon)
0013 %
0014 % IN
0015 %
0016 %   lat    Matrix of latitudes (degrees)
0017 %   lon    Matrix of longitudes (degrees), must have same size as lat
0018 %
0019 % OUT
0020 %
0021 %   mean_lat    Mean vector of latitudes (degrees) for each row of lats
0022 %   mean_lon    Mean vector of longitudes (degrees) for each row of lons
0023 
0024 if ~isequal(size(lat), size(lon))
0025     error(['atmlab:' mfilename ':invalid'], 'lat/lon must have same size');
0026 end
0027 
0028 [x, y, z] = geodetic2cart(0, lat, lon);
0029 [~, mean_lat, mean_lon] = cart2geodetic(mean(x, 2), mean(y, 2), mean(z, 2));
0030 
0031 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005