get_data_from_dr_to_mat

 

Description

Get data from input data range, then put it to matrix

Syntax

bool get_data_from_dr_to_mat( const DataRange & dr, matrixbase & mat, bool bRemoveMissingRows = true, bool bRemoveMissingCols = true )

Parameters

dr
[input] data range.
mat
[output] matrix with data getted.
bRemoveMissingRows
[input] remove rows consisting entirely of missing values.
bRemoveMissingCols
[input] remove cols consisting entirely of missing values.

Return

Return true for success, otherwise false .

Examples

EX1

void get_data_from_dr_to_mat_Ex1()
{
        Worksheet wks;
        wks.Create("origin");
        Dataset ds1(wks,0);
        Dataset ds2(wks,1);
        ds1.Data(1,20,1);
        ds2.Data(20,1,-1);
        
        DataRange dr;
        dr.Add(wks, 0, "X");
        dr.Add(wks, 1, "Y");
        
        matrix mData;
        BOOL bRet = get_data_from_dr_to_mat(dr, mData);
        if(bRet)
        {  
                MatrixLayer ml;
                ml.Create();
                MatrixObject mo;
                mo = ml.MatrixObjects();
                matrixbase& mat = mo.GetDataObject();
                mat = mData;
                printf("The matrixLayer will show the data that matrix gets from datarange\n");
        }
        else
                printf("Failed to get\n");
}

Remark

See Also

get_xy_data

header to Include

origin.h

Reference