CLsqFit:IsCoefForced
The IsCoefForced method determines if a specified coefficient has been forced to a value.
bForced = CLsqFit:IsCoefForced( nIndex, nChan* ) |
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:
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 |
|