2.2.3.8.1 Matrix::AttachAttach
Description
Attach matrix object to internal Origin matrix
Attach a Matrix object to an internal Origin matrix by a MatrixLayer object.
Syntax
BOOL Attach( LPCSTR lpcszMatrixName )
BOOL Attach( MatrixLayer & mlMatLayer, int nMatObj = -1 )
Parameters
- lpcszMatrixName
- [input] name of matrix in Origin to attach to
- mlMatLayer
- [input] MatrixLayer object
- nMatObj
- [input] MatrixObject index, -1 to get the Active MatrixObject
Return
Returns TRUE if attachment is successful and FALSE if unsuccessful.
Returns TRUE if attachment is successful and FALSE if unsuccessful.
Examples
EX1
int Matrix_Attach_ex1()
{
// Assumes Matrix1 exists in Origin
double dMean;
Matrix matA; // Declare OC Matrix object
matA.Attach("MBook1"); // Attach OC object to internal Origin matrix
dMean = matA.GetMean(); // Use matrixbase::GetMean function
printf("Mean of Matrix1: %g\n", dMean ); // Print out mean
return 0;
}
EX2
// Attach the Matrix object to the matrix layer
void Matrix_Attach_ex2()
{
// Assumes a matrix window is active in Origin workspace
MatrixLayer MatLy1; // Declare OC MatrixLayer object
MatLy1 = (MatrixLayer) Project.ActiveLayer(); // Get active MatrixLayer from OC Project object
Matrix Mat1; // Declare OC Matrix object
Mat1.Attach(MatLy1); // Attach the Matrix object to the matrix layer
//Matrix Mat1(MatLy1); // *** Note: Above 2 lines can be replaced with this line. ***
matrix mat1 = {
{1, 2, 3},
{4, 5, 6}
};
Mat1=mat1; // Assigning the matrix values setting in the proper matrix sizes
}
Remark
Attach a Matrix object to an internal Origin matrix by a MatrixLayer object.
See Also
Matrix::Detach,Matrix::IsValid,Matrix::Matrix
Header to Include
origin.h
|