CLsqFit:SetPtObs
The SetPtObs method alters the observed value of an existing sample point. The point must have been previously added to the sample using AddPt or AddPtWt.
CLsqFit:SetPtObs( nIndex, nY ) CLsqFit:SetPtObs( nIndex, nY, nChannel ) where |
nIndex is the index of the point in the sample, beginning at index 1.
nChannel is the optional channel to select for multi-channel data.
nY is the new value to assign the point.
If the point uses multi-channel data, then the nY argument may be a number or a string. In that case, to set all channels together, pass nY as a multi-channel string and ignore the nChannel parameter. To set one channel, pass a number for nY. If working with multi-channel data and you are targeting a particular channel, set the nChannel argument to the target channel.
The SetPtObs method uses the index of the target point. The index must either be known from the order that points were added to the sample, or determined by matching the target point's values using FindPt or a more complicated procedure such as using GetResid to identify the indices of points having high residuals from the fit. You also may fetch the weight currently assigned to a point using GetPtObs.
The following example illustrates how to change the weight of an existing point. In this case, the target point's index is found by matching its values:
|
-- create a CLsqFit object |
|
-- set 2 coefficients to fit a line |
|
-- add a point for x = 3.5, y = 5.15, weight = 1 |
|
-- add more points |
|
-- Fit the line |
|
-- do something with the fit results |
|
-- find the point (if we don't know it has index 1) |
|
-- get the point's y value |
|
-- add 0.05 to the point value |
|
-- get a new fit result using different weights |