CLsqFit:SetBasisFunc
The SetBasisFunc method selects the basis function to use for the fit. This function selects the two built-in basis functions or a named custom basis function you specify in the script. Before writing a custom basis function, read the Basis Functions topic.
CLsqFit:SetBasisFunc( BasisFuncChoice ) |
BasisFuncChoice is a number 1 or 2 for a built-in basis function.
BasisFuncChoice is a string giving the name of a user-provided function written in the script.
This function takes either a number of string value to select the basis function. Mira interprets a number value as a built-in basis function. A string is interpreted as the name of a function in the script:
1 |
The built-in (default) n-dimensional polynomial basis function. |
2 |
The built-in hyperplane basis function. |
strName |
The name of a user-provided basis function declared in the script. |
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= '2' |
The next example declares a user-defined basis function in the script. This function fits a line:
|
-- 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], or 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 more points to the fit |
|
|
-- fit the data |
|
|
|
-- result: Func= 'Line' |
CLsqFit class, GetBasisFunc, GetBasisDim, SetNumCoefs, Basis Functions
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.