CLsqFit:SetNumCoefs CLsqFit:SetNumChannels

CLsqFit:GetNumCoefs


The GetNumCoefs method returns the number of coefficients used in the fit or the number of coefficients used in the n-th dimension of the n-dimensional polynomial fit.

Syntax

CLsqFit:GetNumCoefs( nDim* )

Remarks

This method returns a value between 1 and the total number of coefficients set by the SetNumCoefs method. Depending on the basis function being used, this method returns the values described below:

Examples

The first example, below, defaults to fitting the built-in n-dimensional polynomial. This script specifies 3 coefficients for fitting a 2nd order polynomial to 1 variable. Since only 1 argument is specified, the polynomial fits 1 independent variable.

L = CLsqFit:new()

-- create a CLsqFit object

L:SetNumCoefs( {3, 5} )

-- set 3x5 coefficients for the n-dimensional polynomial

n = L:GetNumCoefs()

-- return the number of coefficients

Printf( "n = %d\n", n )

-- result: n= 15

n = L:GetNumCoefs(1)

-- return the number of coefficients in dimension 1

Printf( "n[%d] = %d\n", 1, n )

-- result: n[1] = 3

n = L:GetNumCoefs(2)

-- return the number of coefficients in dimension 2

Printf( "n[%d] = %d\n", 2, n )

-- result: n[2] = 5

 

 

The next example used a basis function defined in the script (not the built-in n-Dimensional Polynomial). For this case, GetNumCoefs returns the number of coefficients set by the SetNumCoefs method:

L = CLsqFit:new()

-- create a CLsqFit object

L:SetBasisFunc( "F" )

-- specify a basis function named "F"

L:SetNumCoefs( 9, 5 )

-- set 9 coefficients and 5 independent variables

n = L:GetNumCoefs()

-- return the number of coefficients

Printf( "nCoefs = %d\n", n )

-- result: nCoefs = 9

Related Topics

CLsqFit class, Using Multiple Independent Variables, Basis Functions, SetNumCoefs, SetBasisFunc, GetBasisDim