%% linrg.m calculates the linear regression for the given x and y 
%% data set.

function lr=linrg(x,y)

% x = x-coordinates
% y = y-coordinates
% lr = linear regression co-efficent

x=x(:);
y=y(:);

xm=mean(x);
ym=mean(y);
nod=length(x);
lr=(sum(y.*x)-nod*xm*ym)./(sqrt(sum(x.^2)-nod*xm^2).*sqrt(sum(y.^2)-nod*ym^2));
