CLsqFit:UndeletePt CLsqFit:ResetPoints

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.

Syntax

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 )

Remarks

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.

Examples

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

L:AddPt( 3.5, 5.15 )

-- 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

n = L:FindPt( 3.5, 5.15 )

-- find the point (if we don't know it has index 1)

if L:GetPtWt(n) > 5 then

-- if the point has weight > 5

  L:SetPtWt( n, 2.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

L:AddPt( {3,4,5}, 7.25 )

-- 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

n = L:FindPt( {3,4,5}, 7.25 )

-- find the point (if we don't know it has index 1)

if L:GetPtWt(n) > 5 then

-- if the point has weight > 5

  L:SetPtWt( n, 2.5 )

-- reduce the weight of the point to 2.5

end

 

L:Fit()

-- get a new fit result using different weights

Related Topics

CLsqFit class, AddPt, Working with RGB data