f



Best Fit Line

Hello,
       I have a problem that is puzzling me for very long.I got this
problem of fitting in 80 over text files and within each txt file,it
contains about 120 datas.I want to from these datas generate a best
fit line to cut through all these points.The program I am now using is
Matlab.Please help and reply asap,as I need the info urgently.
       Thanks.

0
12/6/2003 2:40:06 AM
comp.soft-sys.matlab 211265 articles. 25 followers. lunamoonmoon (257) is leader. Post Follow

1 Replies
385 Views

Similar Articles

[PageSpeed] 36

In article <a488ubsdofj7@legacy>,
 kellyblue19@yahoo.com (Eid) writes:
 >Hello,
 >        I have a problem that is puzzling me for very long.I got this
 >problem of fitting in 80 over text files and within each txt file,it
 > contains about 120 datas.I want to from these datas generate a best
 >fit line to cut through all these points.The program I am now using is
 >Matlab.Please help and reply asap,as I need the info urgently.
 >       Thanks.
 >

read the files using fscan into intermediate xx,yy (row)vectors.
initialize the final x and y vector with [];
then for every file do
  x=[x,xx];
  y=[y,yy];
finally 
  n=length (x); %total number of points
  coeff=[ones(n,1),x']\(y');
the line then is 
   coeff(1)+coeff(2)*x;
hth
peter

0
12/9/2003 11:14:38 AM
Reply: