Linear fit in matlab

Get Matlab Help Now..!

Linear fit tries to model the relationship between two variables by fitting a linear equation to observed dataset. One variable is assumed to be an explanatory variable, and the other is assumed to be a dependent variable. Equation of linear regression line will be in the form of Y = a + bX, where X is the explanatory variable and Y is the dependent variable. The slope of this line is b, and a is to be the intercept (the value of y when x = 0). For example, a modeler may desire to relate the weights of individuals to their heights using a linear regression model.

The most common method for doing regression line fitting is the method of least-squares. This method evaluates the best-fitting line for the observed data by reducing the sum of the squares of the vertical deviations from each data point of the line (if a point lies on the fitted line correctly then its vertical deviation is 0). Because the deviations are first squared, then they are summed, so there are no cancellations between positive and negative values.

Before trying to fit a linear model to observed dataset, a modeler might first determine whether or not there is a relationship among the variables of interest. This does not necessarily implies that one variable causes the other (for example, higher SAT scores do not result into higher college grades), but that there is some considerable association between the two variables. A scatterplot will be a helpful tool in determining the strength of the relationship between two variables. If there seems to be no association between the proposed explanatory and dependent variables (i.e., the scatterplot does not indicate any increasing or decreasing trends), then fitting a linear regression model to the dataset probably will not provide a useful model.