CLsqFit:delete CLsqFit:GetBasisFunc

CLsqFit:SetBasisFunc


The SetBasisFunc method selects the basis function to use for the fit. This function selects one of the two built-in basis functions or a function you specify in the script..

Syntax

CLsqFit:SetBasisFunc( selection )

Remarks

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.

(else)

The name of a basis function defined in the script.

Note that the value returned by GetBasisFunc is always a string. The number index 1 or 2 is returned as a string as is the name of a basis function declared in the script.

Examples

The following script selects the built-in hyperplane basis function.

L = CLsqFit:new()

-- create a CLsqFit object

 

-- no function declared, n-dimensional polynomial (1) assumed

L:SetBasisFunc( 2 )

-- select built-in function 2, the Hyperplane

sName = L:GetBasisFunc()

 

Printf( "Func= '%s'\n", sName )

-- result: Func= '2'

To next example declares a basis function in the script and then registers it for use. This function fits a line about the origin:

function Line( n, c )

-- declase the basis function

  b = {}

-- declare a lua table for the basis vector

  b[1] = 1

-- basis vector element [1] is 1

  b[2] = c[1]

-- basis vector element [2] is c[1]

  return b

-- return the basis vector

end

-- end of the basis function

L = CLsqFit:new()

-- create a CLsqFit object

L:SetBasisFunc( "Line" )

-- register the script function "F"

sName = L:GetBasisFunc()

 

Printf( "Func= '%s'\n", sName )

-- result: Func= 'Line'

Related Topics

CLsqFit class, GetBasisFunc, GetBasisDim, Basis Functions