% regression_demo2.m
% 
% This is an example of a linear regression with three coefficients, B0,
% B1, and B2, for the Steinhart-Hart equation. These coefficients are labeled C1, C2, and
% C3, respectively in the equation in my notes.

% Measured Resistance values
R = [37e3 20e3 10e3 5e3 4e3 2e3]';

% Observed temperatures, corresponding to resistance matrix
T = [0 10 25 38 50 80]';

% Convert temperatures to Kelvin and create Y = 1/T
Y = 1./(T + 273.15);

X = [ones(size(R)) log(R) (log(R).^3)];  % the first column of this matrix must be 1's

% Perform linear reqression using least squares to solve for the
% coefficients B0, B1, and B2.
% B: a matrix of the coefficients, starting with B0
% BINT: a matrix of the confidence intervals (95% confidence) for each coefficient
% R: a matrix of the residuals
% RINT: a matrix of the confidence intervals (95% confidence) of the residuals, centered
% around each residual
[B, BINT, R, RINT] = regress(Y,X);

