temp = load('temp.dat');

y = temp(:, 1);
t = temp(:, 2);
n = size(temp, 1);
k = 2;

junk = zeros(n, 2*k);
for i = 1:k
    junk(:,i) = cos(2*pi*t*i/72);
    junk(:,i+k) = sin(2*pi*t*i/72);
end

lm_temp = regress(y, [ones(n, 1), junk(:, [1,3])]);
lm_temp2 = regress(y, [ones(n, 1), junk]);

plot(t, y, '-k', 'LineWidth', 2)
hold on;
plot(t, [ones(n, 1), junk(:, [1, 3])]*lm_temp, ':b', 'LineWidth', 2)
plot(t, [ones(n, 1), junk]*lm_temp2, '--r', 'LineWidth', 2)

set(gca, 'Box', 'off', 'FontSize', 22, ...
         'XLim', [0, 360], 'YLim', [36.6, 38.4], ...
         'XTick', 0:72:288, 'YTick', 36.5:0.5:38.5, ...
         'XTickLabel', 0:4, 'TickDir', 'out')

cS = strcat('Temperature (', char(176), 'C)');
xlabel('Time (days)', 'FontSize', 22)
ylabel(cS, 'FontSize', 22)

set(gcf, 'Position', [200, 100, 1400, 600])