%Input:
%   x is a column vector of domain (input) variables
%   y is a column vector of range (output) variables
%
%Output:
%   m is the slope of the line
%   b is the intercept of the line

function [m,b] = ls_interp(x,y)

%Compute the matrix X


P = size(x,1)

c1 = ones(P,1)

X = [c1 x]

vec = X\y

b = vec(1)
m = vec(2)

%plot results
plot(x,y,'o')
hold
plot(x,m*x+b,'--v')
legend('data','model')


