% Plot weighted Cricket model
load 'cricketmore.data'
N = cricketmore(:,1);
T = cricketmore(:,2);
A1 = [N.^0,N];
a1 = A1\T;
A2 = [N.^0,N,N.^2];
a2 = A2\T;
A3 = [N.^0,N,N.^2,N.^3];
a3 = A3\T;
A4 = [N.^0,N,N.^2,N.^3,N.^4];
a4 = A4\T;

xx = linspace(50,250,50);
y1 = 0.215476*xx+39.7741;
y2 = -0.000640761*xx.^2 + 0.396254*xx + 27.8489;
y3 = 0.00000189772*xx.^3 - 0.00144514*xx.^2 + 0.505399*xx + 23.1380;
y4 = -0.0000000176453*xx.^4 + 0.0000118951*xx.^3 - ...
    0.00350440*xx.^2 + 0.687559*xx +  17.3136;
plot(N,T,'bo');
hold on
plot(xx,y1,'b-','LineWidth',1.5);
plot(xx,y2,'r-','LineWidth',1.5);
plot(xx,y3,'-','color',[0,0.6,0],'LineWidth',1.5);
plot(xx,y4,'-','color',[0.5,0,0.5],'LineWidth',1.5);
grid
h = legend('Data','Linear','Quadratic','Cubic','Quartic',...
    'Location','northwest');
set(h,'Interpreter','latex')

% Set up fonts and labels for the Graph
fontlabs = 'Times New Roman';  
xlabel('$N$, Chirps/min','FontSize',16,'FontName',fontlabs, ...
    'interpreter','latex');  
ylabel('Temperature, $^\circ$F','FontSize',16,'FontName',fontlabs, ...
    'interpreter','latex'); 
mytitle = 'Cricket Thermometer';
title(mytitle,'FontSize',16,'FontName', ...
    'Times New Roman','interpreter','latex'); 
set(gca,'FontSize',16);

print -depsc cricket_c.eps