echo on
load temperature           %Load temperature data
plot(time, temp)           %Plot
hold on

k2 = polyfit(time,temp,2); %Second order fit
ft2 = polyval(k2,time);    %Evaluate polynomial
plot(time, ft2, 'r')       %Plot

k4 = polyfit(time,temp,4); %Fourth order fit
ft4 = polyval(k4,time);    %Evaluate polynomial
plot(time, ft4, 'k')       %Plot

xlabel('Time (hours)')
ylabel('Temperature (degrees F)')
title('Temperature change for typical February day')
legend('Temperature Data', 'Second Order Fit', 'Fourth Order Fit', 2)
echo off