2.6 Setting and Getting Matrix Data

In this tutorial, we will show you how to operate on Origin matrix in Labview. We first create two matrixes in Origin and set value to one of the matrix. Then transfer the transposed matrix data to another matrix.

Note that the subVis related to matrix access are in OriginMatrix_LV7.llb. If you have followed the instruction, you can simply get them through All Functions/ User Libraries/ OriginMatrix from Functions palette.

1. Run Labview, create a new VI and active the Block Diagram window. Then choose OA_ConnectToOrigin VI OA ConnectToOrigin App.jpg and place it to the window.

2. Select and place OA_NewMatrixsheet VI OA NewMatrixsheet1.png, then wire the Origin.IOApplication and Error IO connectors to the corresponding connectors of the OA_ConnectToOrigin VI.

3. Select All Functions/ Application Control from Functions palette and place Invoke Node VI InvodeNode.png on the diagram. Then wire reference connector to Origin.MatrixSheet connector of OA_NewMatrixsheet VI. And wire Error IO connector to the corresponding connector of the OA_NewMatrixsheet VI too. After wired the connectors, this VI will be like InvodeNode2.png, click on Method and choose Execute from the fly-out menu. Then add a string constant and set it to matrix -v 10*i + j, and then wire it to the LabTalkStr connector.


4. Select and place another OA_NewMatrixsheet VI OA NewMatrixsheet1.png, then wire the Origin.IOApplication to the corresponding connector of the first OA_NewMatrixsheet VI. And wire the Error IO to the corresponding connector of the Invoke Node VI.


5. Select and place OA_GetMatrix VI OA GetMatrix1.png, then wire the Origin.MatrixSheet connector to the corresponding connector of the Invoke Node VI. And wire the Error IO to the corresponding connector of the second OA_NewMatrixsheet VI.

6. Select and place OA_Mat-GetData VI OA Mat-GetData1.png, and then wire the Origin.Matrix and Error IO connectors to the corresponding connectors of the OA_GetMatrix VI.

7. Select and place OA_GetMatrix VI OA GetMatrix1.png, then wire the Origin.MatrixSheet to the corresponding connector of the second OA_NewMatrixsheet VI. And wire the Error IO to the corresponding connector of the OA_Mat-GetData VI.


8. Select and place OA_Mat-SetData VI OA Mat-SetData1.png, and then wire the Origin.Matrix and Error IO connectors to the corresponding connectors of the OA_GetMatrix VI.

9. Select All Function/ Array from Functions palette and place Transpose 2D Array VI Transpose2DArray.png, then wire the 2D array and transposed array connectors to the Data connectors of OA_Mat-GetData VI and OA_Mat-SetData VI separately.

10. When all of these are finished, the Block Diagram should look like:

MatrixTutorial.png

11. Click Run button to run this VI and then you can turn to Origin to see the result.