Minimum Origin Version Required: Origin8 SR0
This section introduced access data from Origin matrix window.
More related details please reference to the following Origin C Reference sections:
MatrixPage class
MatrixLayer class
MatrixObject class
matrixbase class
matrix class
Matrix class
void AccessMatrixDoubleType() { MatrixPage matPage; matPage.Create("Origin"); MatrixLayer ml = matPage.Layers(0); // get the first matrix sheet int nObjectIndex = 0; MatrixObject mo = ml.MatrixObjects(nObjectIndex); // get the first matrix object mo.SetSize(5, 5); // set size to 5 rows with 5 columns double xmin = 1, xmax = 10, ymin = 1, ymax = 10; mo.SetXY(xmin, xmax, ymin, ymax); // set x/y from and to // set z values Matrix mat(ml, nObjectIndex); for(int ii=0; ii<mat.GetNumRows(); ii++) for(int jj=0; jj<mat.GetNumCols(); jj++) { mat[ii][jj] = ii + jj; } }
void AccessMatrixComplexType() { MatrixPage matPage; matPage.Create("Origin"); MatrixLayer ml = matPage.Layers(0); // get the first matrix sheet int nObjectIndex = 0; MatrixObject mo = ml.MatrixObjects(nObjectIndex); // get the first matrix object mo.SetSize(5, 5); // set size to 5 rows with 5 columns mo.SetInternalData(FSI_COMPLEX); // set internal data type to complex, default is double // set z values Matrix<complex> mat(ml, nObjectIndex); for(int ii=0; ii<mat.GetNumRows(); ii++) for(int jj=0; jj<mat.GetNumCols(); jj++) { complex cc(ii, jj); // construct a complex data with ii as real and jj as imaginary mat[ii][jj] = cc; } }