CLsqFit:GetCoef


The GetCoef method returns the value of a fit coefficient.

Syntax

nValue = CLsqFit:GetCoef( nIndex )

nValue = CLsqFit:GetCoef( nIndex, nChannel )

nV1, nV2, nV3, nV4 = CLsqFit:GetCoef( nIndex )

bullet.gif    nIndex is a number between 1 and GetNumCoefs.

bullet.gif    nValue is the returned value of the coefficient.

bullet.gif    nChannel is an optional argument that specifies the channel for multi-channel (RGB) data.

bullet.gif    nV1, nV2, nV3, and nV4 are values returned for multi-channel data when no channel is specified.

Remarks

This function returns the coefficient at the specified index. If multi-channel data has been enabled, then values are returned for all channels unless you specifically specify a channel. The errors of the coefficients can be obtained using GetCoefErr and the covariance between coefficients can be obtained using GetCovar.

If using the built-in n-dimensional polynomial basis function with n > 1, then the index of the coefficient must be determined by calculating it from the polynomial dimensions or by using GetPolyCoefIndex.

Example

The following script retrieves the constant valued coefficient at index 1,1 after doing a 2x2 polynomial fit. The n-dimensional polynomial is selected by default and no other basis function is specified using SetBasisFunc. As with all sample scripts, this script is very wordy for for purposes of clarity and the statements near the end could be more tightly coded.

L = new_lsqfit()

-- create a CLsqFit object

L:SetNumCoefs( {2,2} )

-- set 2x2 coefficients to fit a warped plane

L:AddPt( {3, 5}, 5.15 )

-- add a point with x = 3, y = 5, z = 5.15

-- add more points to the fit

 

L:Fit()

-- Fit the polynomial

i = 1 j = 1

-- select coefficient at 1, 1

n = L:GetPolyCoefIndex( i, j )

-- fetch the index of the coefficient at i, j

v = L:GetCoef( n )

 

Printf( "Coef[%d][%d]= %lg\n", i, j, v )

-- list the coefficient value

Related Topics

CLsqFit class, GetCoefErr, GetCovar, SetNumCoefs, GetPolyCoefIndex


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.