clear

% Enter Data
x=[.1 .2 .3 .4 .5];
y=[1.089 2.042 2.6710 3.5150 4.4060];

% Plot (xfit, yfit) for model
xfit = linspace(0,.6,20);

% Force Intercept to zero - or [ones(length(x'),1) x']\y' w/intercept
 m=x'\y';
 
% Plot (xfit, yfit) for model
yfit = m*xfit;
plot(xfit,yfit,x,y,'o');

% R^2 Value 
ymodel = m*x;              % predicted values
resid  = y - ymodel;       % residuals
dev = y - mean(y);         % deviations - measure of spread
SST = sum(dev.^2);         % total variation accounted for
SSE = sum(resid.^2);       % variation NOT accounted for
Rsq = 1 - SSE/SST;         % percent of error explained

Rsq2=sum(ymodel)/sum(y);   % 
