CLsqFit:FindPt
The FindPt method returns the index of a point based on matching its values and, optionally, its channel. If a channel is specified, then the index returned is the index of the point for that channel.
n = CLsqFit:FindPt( x, V, nChan* ) n = CLsqFit:FindPt( tableX, V, nChan* ) n1, n2, n3, n4 = CLsqFit:FindPt( x, V ) n1, n2, n3, n4 = CLsqFit:FindPt( tableX, V ) |
The FindPt method returns the index of the target point in the sample data of the specified channel. If the channel is omitted, then the only channel, or first channel of multi-channel data, is searched. The arguments of this method are similar to that of the AddPt method except that an optional channel index may be specified.
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:
L = CLsqFit:new() |
-- create a CLsqFit object |
L:SetNumCoefs( 2 ) |
-- set 2 coefficients |
|
-- add a point for x = 3.5 and y = 5.15 |
|
-- add more points |
L:Fit() |
-- Fit the line |
|
-- do something with the fit results |
|
-- find the point (if we don't know it has index 1) |
|
-- if the point has weight > 5 |
|
-- reduce the weight of the point to 2.5 |
end |
|
L:Fit() |
-- get a new fit result using different weights |
The next example illustrates how to change the weight of a point having more than 1 independent variable. This requires passing the independent variables using a table:
L = CLsqFit:new() |
-- create a CLsqFit object |
L:SetNumCoefs( 5, 3 ) |
-- set 5 coefficients and 3 independent variables |
|
-- add a point with tableX = {3,4,5} and V = 7.25 |
|
-- add more points |
L:Fit() |
-- Fit the function |
|
-- do something with the fit results |
|
-- find the point (if we don't know it has index 1) |
|
-- if the point has weight > 5 |
|
-- reduce the weight of the point to 2.5 |
end |
|
L:Fit() |
-- get a new fit result using different weights |