CLsqFit:SetNumChannels


The SetNumChannels method specifies the number of channels to fit. Use this method to set 3 or 4 channels, as for fitting RGB or RGBa data. This method need not be called if fitting numeric data of 1 channel (the default).

Syntax

CLsqFit:SetNumChannels( nChannels )

where

    nChannels is the number of channels to use, in the range 1 to 4.

  

The SetNumChannels method set the number of channels for the data points. This method must be called before adding points using AddPt and AddPtWt. The default is 1 channel. The number of channels in current use may be retrieved using GetNumChannels.

Examples

The following script sets 3 channels, adds data points, and lists the number of channels in use:

L = CLsqFit:new()

-- create a CLsqFit object

L:SetNumChannels( 3 )

-- specify 3 channel data

L:AddPt( 3.5, "5,240.4,140" )

-- add a point for x = 3.5 and y = "5,240.4,140"

 

-- add more points

L:Fit()

-- compute the fit

n = L:GetNumChannels()

-- get the number of channels in use

Printf( "nChan= %d\n", n )

-- result: nChan= 3

The next example does not call SetNumChannels, so the default number of channels, 1, is used. The script adds data points and then lists the number of channels in use:

L = CLsqFit:new()

-- create a CLsqFit object

L:AddPt( 3.5, 12.25 )

-- add a point for x = 3.5 and y = 12.25

 

-- add more points

L:Fit()

-- compute the fit

n = L:GetNumChannels()

-- get the number of channels in use

Printf( "nChan= %d\n", n )

-- result: nChan= 1

Related Topics

CLsqFit class

GetNumChannels

CLsqFit class

Working with RGB Data