2.5.21 SetEvenSampling


Description

Set sampling settings of one column

Syntax

VB: Function SetEvenSampling(X0 As ByVal Double, XInc As ByVal Double, [ Units As ByVal Object ], [ LongName As ByVal Object ], [ DispFormat As ByVal Object ] ) As Boolean
C++: bool SetEvenSampling(double X0, double XInc, _variant_t Units, _variant_t LongName, _variant_t DispFormat )
C#: bool SetEvenSampling(double X0, double XInc, var Units, var LongName, var DispFormat )

Parameters

X0
The initial value of X.
XInc
The increment of X.
Units
A string of the unit of X axis. For example, if X axis is a time line, then the Unit could be "ms".
LongName
A string of the LongName of X axis. For example, "Time".
DispFormat
A string of display format of numbers. For example, "%8.2f"

Return

A boolean value with true indicating set successfully and false indicating it is failed.

Remark

Examples

VBA

Connect to the running Origin. Set the interval of samples in Column(0) as 20ms, and send data to the column. You can see the result in Origin. Then, Get the sample rate of the column and output it.

Public Sub SetEvenSampling()
    Dim app As Origin.ApplicationSI
    Dim Wks As Origin.Worksheet
    Dim Data(1 To 100) As Double
    Dim ii As Integer
    For ii = 1 To 100
        Data(ii) = ii * 0.12 + 3.75
    Next
 
    Set app = New Origin.ApplicationSI
    Set Wks = app.FindWorksheet("")
 
    'Set a time line, which unit is ms, starting from 0 and sample interval is 20 ms, and display format is default
    ii = Wks.Columns(0).SetEvenSampling(0, 20, "ms", "Time", "")
 
    'Send data to the column
    Wks.Columns(0).SetData (Data)
 
    'Get the sample rate of the column, and output it to the Excel sheet
    Range("A1") = Wks.Columns(0).EvenSampling
 
End Sub

C#

Using Origin;
static void SetEvenSampling()
{
    double[] Data = new double[100];
    for (int ii = 0; ii < 100; ii++)
    {
        Data[ii] = ii * 0.12 + 3.75;
    }

    Origin.ApplicationSI app = new Origin.ApplicationSI();
    Worksheet wks = app.FindWorksheet("");

    //Set a time line, which unit is ms, starting from 0 and sample interval is 20 ms, and display format is default
    wks.Columns[0].SetEvenSampling(0, 20, "ms", "Time", "");

    //Send data to the column
    wks.Columns[0].SetData(Data, 0);

    //Get the sample rate of the column, and output it to console
    Console.WriteLine(wks.Columns[0].EvenSampling);

    Console.ReadLine();

}

Version Information

8.0SR2

See Also

SetData | EvenSampling