CLsqFit:GetBasisDim
The GetBasisDim method returns the number of dimensions of independent variable. This value was set using the SetNumCoefs method.
nDim = CLsqFit:GetBasisDim() |
This function returns the number of independent variables used in the fit. This equals the dimension of the basis. The sample points must be added with data for the corresponding number of dimensions as shown in AddPt and AddPtWt.
The following script retrieves the number of dimensions used by the basis function being fit.
L = CLsqFit:new() |
-- create a CLsqFit object |
|
-- no function declared, n-dimensional polynomial (1) used |
|
-- Declare a 2x2 coefficient fit |
|
-- fetch the number of basis dimensions |
|
-- result: Dim = 2 |
The next example defines a basis function in the script and registers it, The basis function fits 2 coefficients to one independent variable (i.e., 1 dimension). The script then fetches the basis function properties.
function MyFunc( n, c ) |
-- declare a basis function |
b = {} |
|
b[1] = 1 |
|
b[2] = c[1] |
|
return b |
|
end |
-- end of basis function |
L = CLsqFit:new() |
-- create a CLsqFit object |
|
-- register the basis function |
|
-- fit 2 coefficients in 1 dimension |
|
|
|
-- fetch the number of basis dimensions |
|
-- result: Dim 'MyFunc' = 1 |