CLsqFit:SetBasisFunc
The SetBasisFunc method selects the basis function to use for the fit. This function either selects one of the two built-in basis functions or specifies the name of a user-defined function declared in a script. Before writing a custom, user-defined, basis function, read the Basis Functions topic.
CLsqFit:SetBasisFunc( sBasisFuncChoice ) |
sBasisFuncChoice is the name of a built-in basis function.
sBasisFuncChoice is a string giving the name of a user-provided function declared in a script.
The value of sBasisFuncChoice is a string interpreted as follows:
"polynomial" |
The built-in (default) n-dimensional polynomial basis function. |
"hyperplane" |
The built-in hyperplane basis function. |
sFuncName |
The name of a user-provided basis function declared in the script. This is case sensitive. |
The following script selects the built-in hyperplane basis function.
|
-- create a CLsqFit object |
|
-- no function declared, so n-dimensional polynomial used |
|
-- select built-in function 2, the Hyperplane |
|
|
|
-- result: Func= 'hyperplane' |
The next example declares a user-defined basis function in the script. This function fits a line. Its name is passed as a string parameter to SetBasisFunc. Remember that your custom basis function name is case-sensitive.
|
-- declare the basis function. n is always passed as 2. |
|
-- declare a local table for the basis vector |
|
-- basis vector element [1] is 1 |
|
-- basis vector element [2] is c[1], the "x" coordinate |
|
-- return the basis vector |
|
-- end of the basis function |
|
-- create a CLsqFit object |
|
-- register the script function "Line" |
|
-- set the number of coefs for a 1-dimensional fit. |
-- add points to the fit |
|
|
-- fit the data |
|
|
|
-- result: Func= 'line' |
Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.