% Cricket Chirping Data
T = [69.4 69.7 71.6 75.2 76.3 79.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.6 17.1 17.2 16.2 17.0 18.4 ...
20.0 19.8];

% Estimate rates of change at each point (not including end points
for i = 2:length(T)-1
   % average rate of change from i-1 to i 
   L = (C(i)-C(i-1))/(T(i)-T(i-1));
   
   % average rate of change from i to i+1
   R = (C(i+1)-C(i))/(T(i+1)-T(i));
   
   % estimate rate of change at i
   RoC(i) = (L+R)/2;
end

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

% Plot out rate of change information
subplot(2,1,2); plot(T(2:length(T)-1),RoC(2:length(T)-1),'go-')
xlabel('Temperature \circF')
ylabel('Chirps/second/\circF')