In matlab the lsline command fits a line through a set of plotted data points. The overdetermined system can be solved in a least squares sense by simply . The command p=polyfit(t,y,n) gives the coefficients of the degree polynomial which fits the data points in a least squares sense. To calculate the values of this polynomial at points we use polyval(p,x).