2.1.40 PutMatrix


Description

Put two dimensional data into a specified Origin matrix.

Syntax

VB: Function PutMatrix(Name As ByVal String, data As ByVal Object ) As Boolean
C++: bool PutMatrix(LPCSTR Name, _variant_t data )
C#: bool PutMatrix(string Name, var data )

Parameters

Name
The range string of the Origin worksheet to be found. The range string contains the book name between square brackets followed by the sheet name:
[<bookName>]<sheetName>!<objIndex>
The following special notations are supported. When any of the three parts are not specified then the active is used:
  1. "" (empty string) -- get the active object from the active sheet from the active book
  2. "[MBook1]" or "MBook1" -- get the active object from the active sheet from the named book
  3. "[MBook1]MSheet1" or "[MBook1]MSheet1!" -- get the active object from the named sheet from the named book
  4. "MSheet!" -- get the active object from the named sheet from the active book
  5. "MSheet!0" -- get the specified object from the named sheet from the active book
data
Two dimensional safearray containing the data that will be put into the Origin matrix.

Return

The PutMatrix method returns true if successful else false.

Remark

Examples

VBA

'Assumes Matrix1 exists.
Dim oApp As Origin.ApplicationSI
Dim bb As Boolean
Dim mat(5, 1 To 2) As Long
Set oApp = GetObject("", "Origin.ApplicationSI")
'Create sample data
For i = 0 To 5
For j = 1 To 2
mat(i, j) = i + j
Next j
Next i
bb = oApp.PutMatrix("Matrix1", mat)

C#

using Origin;
static bool TestPutMatrix()
{
	Origin.ApplicationSI originApp = new Origin.ApplicationSI();

	int nNumRows = 100;
	int nNumCols = 100;

	// Create some data to put into the matrix.
	double[,] data = new double[nNumRows, nNumCols];
	for (int nRow = 0; nRow < nNumRows; nRow++)
		for (int nCol = 0; nCol < nNumCols; nCol++)
			data[nRow, nCol] = (double)(nCol + nRow);

	// Start a new Origin project.
	originApp.NewProject();

	// Create a new matrix book.
	MatrixPage mpg = originApp.MatrixPages.Add("origin", System.Type.Missing);

	// Get the first matrix sheet in the new book.
	MatrixSheet msht = mpg.Layers[0] as MatrixSheet;
	msht.Rows = nNumRows;
	msht.Cols = nNumCols;

	// Construct a full sheet name to pass to PutMatrix.
	string strMSheetName = "[" + mpg.Name + "]" + msht.Name;

	// Put the data into the matrix sheet.
	return originApp.PutMatrix(strMSheetName, data);	
}

Python

import OriginExt as O
app = O.Application(); app.Visible = app.MAINWND_SHOW
pageName = app.CreatePage(app.OPT_MATRIX)
mp = app.MatrixPages(pageName)
ms = mp.Layers(0)
# Set number of matrix objects
ms.Mats = 1
# Set the dimension of matrix
ms.Rows = 3; ms.Cols = 2
# Set the data of matrix object
testData = [[5,87,90], [3.14, 24.6, 68.09]]
app.PutMatrix(pageName, testData)
outputData = app.GetMatrix(pageName)

Version Information

8.0SR2

See Also

GetMatrix