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

%This function is to compute the slope and y intercept of the
%least squares fit.  x and y are N element column vectors in which
%the Nth elemnent of x and y correspond to one data point.

%    Copyright (C) 1996  Brad North

%    This program is free software; you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as published by
%    the Free Software Foundation; either version 2 of the License, or
%    (at your option) any later version.

%    This program is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.

%    You should have received a copy of the GNU General Public License
%    along with this program; if not, write to the Free Software
%    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

%    Problems, Comments, and Suggestions can be sent to 
%            northbh@nextwork.rose-hulman.edu

%Note:  Each time you save this, you must restart the Least Squares
%	program.  This compiles at the same the Least Squares program
%	does, so changing CompSqr does not affect a current running
%	version of Least Squares.




%The answer---------------------------------------
Elements=length(x);
mb=[x ones(length(x),1)]\y;
m=mb(1);
b=mb(2);
%-------------------------------------------------


%Delete this and write the function---------------
%m=0;
%b=0;
%-------------------------------------------------

return;
