CLsqFit:IsCoefForced
The IsCoefForced method determines if a specified coefficient has been forced to a value.
bForced = CLsqFit:IsCoefForced( nIndex ) bForced = CLsqFit:IsCoefForced( nIndex, nChan ) where |
nIndex is the index of the coefficient in the set of coefficients of the fit. This is a 1-based number.
nChan is an optional parameter that specifies the target channel when fitting multi-channel data
bForced is a boolean true or false value that indicates whether a coefficient was forced..
If you are doing a complex fitting procedure and do not remember which coefficients were forced, use this method to query the status of a particular coefficient. To fit all coefficients after some were forced, you can remove all forcing in one step using ResetForcedCoefs.
This method takes a single number for the index of the coefficient to be polled. If you define the basis function in a script, then nIndex is simply an index into your list of coefficients to be fit. Alternatively, when using one of the built-in basis functions the index of the target coefficient is as follows:
n-dimensional polynomial: This method requires use of a helper method to find the coefficient index in the n-dimensional coefficient matrix. See GetPolyCoefIndex.
Hyperplane: The target coefficient can be identified knowing that the first coefficient applies to a constant value,
This example shows how to forcing a coefficient in a 2x2 coefficient polynomial fit. After computing the fit, the cross term between x and y at index 2,2 is removed from the fit by setting it to 0, leaving a fit to an inclined plane rather than a warped plane.
|
-- create the least squares fitting object |
|
-- fit a polynomial with 2 coefficients each in 2 dimensions; |
|
-- add an (x,y) point |
|
-- add more points... |
|
|
|
|
|
|
|
-- find the 2,2 coefficient in the 2x2 polynomial fit matrix |
|
-- remove the cross-term at the 2,2 position |
|
-- use 4 coefficients with the 2,2 coef set to 0.0 |
|
-- check whether the coefficient at 2,2 has been forced |
|
-- prints [4] forced= 1 |