-
Notifications
You must be signed in to change notification settings - Fork 3
/
eqplot.m
59 lines (53 loc) · 1.66 KB
/
eqplot.m
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function varargout=eqplot(lat,dlon,c11cmn,varargin)
% ah=EQPLOT(lat,dlon,[c11 cmn])
%
% Plots an equal-area grid as calculated by AUTHALIC
%
% INPUT:
%
% lat latitudes describing the grid, column vector [degrees]
% dlon longitudes describing the grid, column vector [degrees]
% c11 [x,y]/[lon,lat]-coordinates of the upper left grid corner [degrees]
% cmn [x,y]/[lon,lat]-coordinates of the bottom right corner [degrees]
%
% OUTPUT:
%
% ah A set of graphics handles:
% ah(1:length(lat)) % handles representing lines of latitude
% ah(length(lat)+1:end) % handles for the longitudinal divisions
%
% EXAMPLE:
%
% c11=[110 10]; cmn=[180 -50];
% [lat,dlon,c,nmr]=authalic(c11,cmn,1,5);
% a=eqplot(lat,dlon,[c11 cmn]); set(a(length(lat)+1:end),'color','b')
%
% Last modified by fjsimons-at-alum.mit.edu, 05/30/2022
[c11,cmn]=deal(c11cmn(1:2),c11cmn(3:4));
% Plots lines of constant latitude and returns handles to it
lats=plot([c11(1) cmn(1)],[lat lat],'k');
hold on
if nargin==3
lonm=repmat(NaN,2*size(dlon,1),size(c11(1):min(dlon):cmn(1),2));
for index=1:length(lat)-1
divs=[c11(1):dlon(index):cmn(1)];
lonm(2*index-1,1:length(divs))=divs;
lonm(2*index,1:length(divs))=divs;
end
latm=repmat(lat(2:end-1)',2,1);
latm=latm(:);
latm=repmat([lat(1) ; latm ; lat(end)],1,size(lonm,2));
latm(isnan(lonm))=NaN;
% So a single handle returns a curvy longitudinal line
hands=plot(lonm,latm,'k');
else
for index=1:length(lat)-1
ah=plot(repmat([c11(1):dlon(index):cmn(1)],2,1),...
[lat(index) lat(index+1)],'k');
hands=[hands ; ah];
end
end
axis image
hold off
varns={lats,hands};
varargout=varns(1:nargout);