% Cricket Chirping Data
T = [69.4 69.7 71.6 75.2 76.3 79.6 80.6 80.6 82.0 82.6 83.3 83.5 84.3 ...
88.6 93.3];
C = [15.4 14.7 16.0 15.5 14.4 15.0 16.0 17.1 17.1 17.2 16.2 17.0 18.4 ...
20.0 19.8];

% Plot out data
plot(T,C,'bo')
xlabel('Temperature \circF')
ylabel('Chirps/second')
axis([65 95 13 21])

hold on; % Allows next plot command to print on same graph

% Plot LSR
M = polyfit(T,C,1);
X = 65:95;
plot(X,polyval(M,X),'r-')

hold off; % Next plot command will print on a new graph

% Display the equation
fprintf('Eqn for LSR: C(T) = %f T + %f\n',M(1),M(2))

% Average rate of change in chirps/sec as temp goes from 70 to 80
avg = (polyval(M,80)-polyval(M,70))/(80-70);
fprintf('[C(80)-C(70)]/[80-70] = %f chirps/sec/degree F\n',avg)