d = datetime(2022,6,1:214);
lat = 42.3;
lon = -71.4;
[~,sset] = sunrise_dt(lat,lon,d);
t = hour(sset)+minute(sset)/60+second(sset)/3600;
[~,ixEarliest] = min(t);
[~,ixLatest] = max(t);
d = d(ixLatest:ixEarliest);
t = t(ixLatest:ixEarliest);
sset = sset(ixLatest:ixEarliest);
clf
drawClockFace
gammaHr = pi/2 - 2*pi*mod(t,12)/12;
% colorMap = prism(7);
colorMap = get(gca,"ColorOrder");
colorIxList = [1 1 1 1 1 1 2 3 4 5 6 7];
monthList = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
monthList = monthList(unique(month(d)));
h = zeros(12,1);
nMonths = length(unique(month(d)));
r = 0.8;
for i = 1:length(gammaHr)
colorIx = colorIxList(month(d(i)));
% colorIx = colorIxList(i);
color = colorMap(colorIx,:);
h(colorIx) = line([0 r*cos(gammaHr(i))],[0 r*sin(gammaHr(i))], ...
Color=color, ...
LineWidth=2);
end
r = 1.1;
x = r*cos(gammaHr(1));
y = r*sin(gammaHr(1));
line([0 x],[0 y],Color=0.5*[1 1 1])
sset.Format = "dd-MMM HH:mm";
text(x,y,sprintf("Latest Sunset \n%s ", string(sset(1))), ...
Color=0.5*[1 1 1], ...
VerticalAlignment="top", ...
HorizontalAlignment = "right")
x = r*cos(gammaHr(end));
y = r*sin(gammaHr(end));
line([0 x],[0 y],Color=0.5*[1 1 1])
sset.Format = "dd-MMM HH:mm";
text(x,y,sprintf(" Earliest Sunset \n %s ", string(sset(end))), ...
Color=0.5*[1 1 1], ...
VerticalAlignment="top", ...
HorizontalAlignment = "left")
axis equal
axis off
monthList = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
monthList = monthList(unique(month(d)));
h(h==0) = [];
legend(h,monthList, ...
Comments
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.