% regression_demo1.m
% 
% This is an example of a linear regression with two coefficients, B0 and
% B1 (b and a in the example in class, the y intercept and the slope of
% the line).

% This is using the example data (shown on the excel sheet) from the E80
% lecture slides on 2/17/09

% matrix of x values
x = [1 2 3 4 5]';

% matrix of y (observed outputs)
Y = [1.4 1.8 3.2 4.4 5.1]';

X = [ones(size(x)) x];  % the first column of this matrix must be 1's

% Perform linear reqression using least squares to solve for the
% coefficients B0 and B1.
% 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);

