function [tRise,tSet] = SunRiseAndSet(Lat,Long,Day,Zone)
% Lat and Long specify the latitude and longitude (in degrees) of a city.
% Assume 25 <= Lat <= 55 and 60 <= Long <= 130.
% Day is an integer that specifies a date, e.g.,
% 1 = Jan 1, 90 = Mar 31, 364 = Dec 30.
% tRise and tSet are the local sunrise and sunset times (in hours) at the
% designated city on the designated date. Thus, if tRise = 7.25 and
% tSet = 21.1 then the sun rose at 7:15AM and set at 9:06 PM.
% Zone specifies the time zone of the city, ’EST’, ’CST’, ’MST’, or ’PST’.
if Zone == 'EST'
    timezone = -5;
elseif Zone == 'CST'
    timezone = -6;
elseif Zone == 'MST'
    timezone = -7;
elseif Zone == 'PST'
    timezone = -8;
else
    timezone = 0;
    fprintf('Error: Unrecognized timezone.\n');
end
% Parameters found from LSQNONLIN
x = [
    5.8634
    0.0668
    1.1368
    0.0176
    0.0453
    0.0894
    0.0312
    0.1010
    0.0357
   12.1272
    0.0947
    0.9599
    0.0168
    1.3154];
% Compute tRise, tSet using model
tRise = timezone + x(1) + x(2)*Long ...
    + (x(3) - cos(x(5)*Lat))*cos(x(4)*Day) ...
    + x(6)*cos(x(7)*Day) ...
    + x(8)*sin(x(9)*Day);
tSet = tRise + x(10) + (x(11)*Lat - x(12))*sin(x(13)*Day - x(14));
end
