Contents Previous Next Subchapters

A Dialog for Fitting Polynomials
Syntax polfitdlg
See Also linlsqdlg matrix division

Displays a dialog that controls the linear least squares fitting of a polynomial to two selected columns of an ascii data 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 be given a choice for the degree of the polynomial used in the fit.

The Fit Button
If the Fit button is selected, the following objective function is minimized with respect to the amplitude vector a:
      n                                       2
     --- [                 2               m ]
     >   [ y   -  a  + a  x  + ... + a    x  ]
     --- [  i      1    2             m+1    ]
where n is the number of rows in the data file and m is the degree of the polynomial. The resulting new value for the vector a is displayed in the dialog.

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 Polynomial Fitting dialog. The Help button displays the help for polfitdlg.

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
polynomial degree 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.