External Interfaces Reference |
MATLAB Client
h.PutFullMatrix('varname', 'workspace
', xreal, ximag) PutFullMatrix(h, 'varname', 'workspace
', xreal, ximag) invoke(h, 'PutFullMatrix
', 'varname', 'workspace
', xreal, ximag)
Method Signature
PutFullMatrix([in] BSTR varname, [in] BSTR workspace, [in] SAFEARRAY(double) xreal, [in] SAFEARRAY(double) ximag)
Visual Basic Client
PutFullMatrix([in] varname As String, [in] workspace As String, [in] xreal As Double, [in] ximag As Double)
Description
PutFullMatrix
stores a matrix
in the specified workspace
of the server attached to handle h
, assigning to it the variable varname
. Enter the real and imaginary parts of the matrix in the xreal
and ximag
input arguments. The workspace
argument can be either base
or global
.
Remarks
The matrix specified in the xreal
and ximag
arguments cannot be scalar, an empty array, or have more than two dimensions.
Server function names, like PutFullMatrix
, are case sensitive when using the first syntax shown.
There is no difference in the operation of the three syntaxes shown above for the MATLAB client.
For VBScript clients, use the GetWorkspaceData
and PutWorkspaceData
functions to pass numeric data to and from the MATLAB workspace. These functions use the variant
data type instead of safearray
which is not supported by VBScript.
Example 1 -- Writing to the Base Workspace
Assign a 5-by-5 real matrix to the variable M
in the base workspace of the server, and then read it back with GetFullMatrix
. The real and (optional) imaginary parts are passed in through separate arrays of doubles.
MATLAB Client
h = actxserver('matlab.application'); h.PutFullMatrix('M', 'base', rand(5), zeros(5)) % One output returns real, use two for real and imag xreal = h.GetFullMatrix('M', 'base', zeros(5), zeros(5)) xreal = 0.9501 0.7621 0.6154 0.4057 0.0579 0.2311 0.4565 0.7919 0.9355 0.3529 0.6068 0.0185 0.9218 0.9169 0.8132 0.4860 0.8214 0.7382 0.4103 0.0099 0.8913 0.4447 0.1763 0.8936 0.1389
Visual Basic Client
Dim MatLab As Object Dim XReal(4, 4) As Double Dim XImag(4, 4) As Double Dim ZReal(4, 4) As Double Dim ZImag(4, 4) As Double Dim i, j As Integer For i = 0 To 4 For j = 0 To 4 XReal(i, j) = Rnd() * 6 XImag(i, j) = 0 Next j Next i Matlab = CreateObject("matlab.application") MatLab.PutFullMatrix("M", "base", XReal, XImag) MatLab.GetFullMatrix("M", "base", ZReal, ZImag)
Example 2 -- Writing to the Global Workspace
Write a matrix to the global workspace of the server and then examine the server's global workspace from the client.
MATLAB Client
h = actxserver('matlab.application'); h.PutFullMatrix('X', 'global', [1 3 5; 2 4 6], [1 1 1; 1 1 1]) h.invoke('Execute', 'whos global') ans = Name Size Bytes Class X 2x3 96 double array (global complex) Grand total is 6 elements using 96 bytes
Visual Basic Client
Dim MatLab As Object Dim XReal(1, 2) As Double Dim XImag(1, 2) As Double Dim result As String For i = 0 To 1 For j = 0 To 2 XReal(i, j) = (j * 2 + 1) + i XImag(i, j) = 1 Next j Next i Matlab = CreateObject("matlab.application") MatLab.PutFullMatrix("M", "global", XReal, XImag) result = Matlab.Execute("whos global") MsgBox(result)
See Also
GetFullMatrix
, PutWorkspaceData
, GetWorkspaceData
, Execute
PutCharArray | PutWorkspaceData |
© 1994-2005 The MathWorks, Inc.