Contents Previous Next Subchapters

A Linear Least Squares Fitting Dialog
Syntax linlsqdlg
See Also polfitdlg matrix division

Displays a dialog that controls the linear least squares fitting of an arbitrary set of functions to two selected columns of and ascii data in a file. The file contains double precision values and its columns are separated by white space. The user will be given the choice of one column for the independent variable, x, and another column for the dependent variable, y. In addition, the user will define an expression for each of the fitting functions.

The Fit Button
If the Fit button is selected, the following objective function is minimized with respect to the amplitude vector a:
      n            5               2
     --- [        ---             ]
     >   [ y   -  >   a  * f (x ) ]
     --- [  i     ---  j    j  i  ]
     i=1          j=1
where n is the number of rows in the data file. The resulting new value for the vector a is displayed in the dialog.

Fitting Functions
If a fitting function is blank, it is not included in the fit. Otherwise each fitting function must be defined as an element-by-element expression in terms of a column vector x. (Thus the fitting function evaluates to a column vector with the same length as x.) For example, the expression sin(x) defines the element-by-element sine function of the column vector argument x. There is one exception to this rule: if the character x is not present in the fitting function definition, it is assumed to evaluate to a scalar (for example if the fitting function definition is 1.) In this case, it represents a constant and is the same value independent of the value of x.

The Plot Button
If the Plot button is selected, a plot corresponding to the current dialog settings is displayed in the Graphic 0 window. (Note that you can change the amplitude vector a either directly in the dialog or by choosing the Fit button.) The lower plot contains the residuals plotted as circles. The upper plot contains the data and fitted function values. The data is plotted as circles and the fitted function is plotted as a curve.

Other Buttons
The File button is used to choose a new data file. The Exit button dismisses the Linear Least Squares dialog. The Help button displays the help for linlsqdlg.

If the file temp.dat contains
     1   1   1
     2   4   8
     3   9  27
     4  16  64
     5  25 125
and you enter
O-Matrix will display the following dialog

If you then use the File button to select the file temp.dat, O-Matrix will display the name of the file in the dialog. If you then choose the following setting
x column index 1
y column index 2
f1(x) 1
f2(x) x
f3(x) x^2
and then select the Fit button, O-Matrix will fit a quadratic function to the data and display the resulting amplitude values in the dialog. If you then select the Plot button, O-Matrix will plot the result in the Graphic 0 window. You can use the Exit button to dismiss the dialog.