1.5.2.2 Matrix Sheet Data Manipulation

Conversion Between Matrixsheets and Matrix Objects

In Origin, a matrixsheet can hold multiple matrix objects. Using the matobj_move function, you can split multiple matrix objects into separate matrixsheets, or combine multiple matrixsheets into one (provided all matrices share the same dimensions).

// This code snippet is to merge the matrix objects in three sheets to 
// a new sheet
MatrixPage mp("MBook1");  // Matrixbook
MatrixLayer ml1 = mp.Layers(1);  // 2nd sheet
MatrixLayer ml2 = mp.Layers(2);  // 3rd sheet
MatrixLayer ml3 = mp.Layers(3);  // 4th sheet

MatrixLayer mlMerge;  
mlMerge.Create("Origin");  // Create a new sheet for merging
MatrixObject mo1 = ml1.MatrixObjects(0);  // Matrix object in 2nd sheet
MatrixObject mo2 = ml2.MatrixObjects(0);  // Matrix object in 3rd sheet
MatrixObject mo3 = ml3.MatrixObjects(0);  // Matrix object in 4th sheet
matobj_move(mo1, mlMerge);  // Move the matrix object to the end of the sheet
matobj_move(mo2, mlMerge);
matobj_move(mo3, mlMerge);