function HI = heatIndex(degC, relH)
%HEATINDEX Heat index
% HI = HEATINDEX(degC, relH) returns the heat index HI given
% the air temperature degC in degrees Celcius and the
% relative humidity relH (relH should be between 0 and 100).

% note that the formula does not reproduce the table
% shown on the Wikipedia page exactly; some values will
% vary by 1 or 2 degrees

c1 = -8.78469475556;
c2 = 1.61139411;
c3 = 2.33854883889;
c4 = -0.14611605;
c5 = -0.012308094;
c6 = -0.0164248277778;
c7 = 0.002211732;
c8 = 0.00072546;
c9 = -0.000003582;
T = degC;
R = relH;
HI = c1 + ...
    c2 * T + ...
    c3 * R + ...
    c4 * T * R + ...
    c5 * T^2 + ...
    c6 * R^2 + ...
    c7 * T^2 * R + ...
    c8 * T * R^2 + ...
    c9 * T^2 * R^2;

end
