g_res_field.m 800 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function delta = g_res_field(LAT, LON)

% LAT and LON difference in the x-axis
dLATi = diff(LAT, 1, 2);
dLONi = diff(LON, 1, 2);

% LAT and LON difference in the y-axis
dLATj = diff(LAT, 1, 1);
dLONj = diff(LON, 1, 1);

% Mean LAT in both x and y axis
LAT_meani = 0.5*(LAT(:, 2:end) + LAT(:, 1:end-1));
LAT_meanj = 0.5*(LAT(2:end, :) + LAT(1:end-1, :));

% Conversion from degree to meters
meterPerDegLat = 1852*60.0;
meterPerDegLoni = meterPerDegLat .* cosd(LAT_meani);
meterPerDegLonj = meterPerDegLat .* cosd(LAT_meanj);

dxi = dLONi.*meterPerDegLoni;
dxj = dLONj.*meterPerDegLonj;

dyi = dLATi.*meterPerDegLat;
dyj = dLATj.*meterPerDegLat;

% Distances in x and y axis
deltai = sqrt(dxi.^2 + dyi.^2);
deltaj = sqrt(dxj.^2 + dyj.^2);

% Overall distance
delta = sqrt(deltai.^2 + deltaj.^2);

end