% FindDarkCurrentPolyfit.m
% Author: Greg Wientjes
% Class: EE362
% Date: 3-2-04
% ------------------------------------------------------
% Description: This program reads in the dark current data and determines a
% polynomial function that fits the Dark Current data best.  We then plot
% the results.

load DarkCurrent_AverageAll.mat;
load darkCurrentExposureTimes1.mat;

darkCurrentExposureTimesVector = darkCurrentExposureTimes( 2:56 , 2);

N = 3;  % Fit the data to a polynomial to the 3rd degree.
polyCoeff = POLYFIT( darkCurrentExposureTimesVector, average_3cds', N);

testX = 0:.5:30;
testY = polyCoeff(1)*testX^3 + polyCoeff(2)*testX^(2) + polyCoeff(3)*testX + polyCoeff(4)

% Plot the best fit polynomial found above
figure(2);
plot( testX, testY );
