External Interfaces Reference |
Returns data from variable in server workspace
MATLAB Client
D = h.GetVariable('varname', 'workspace
') D = GetVariable(h, 'varname', 'workspace
') D = invoke(h, 'GetVariable
', 'varname', 'workspace
')
Method Signature
Visual Basic Client
Description
GetVariable
returns the data stored in the specified variable from the specified workspace of the server. Each syntax in the MATLAB Client section produce the same result. Note that the dot notation (h.GetVariable
) is case sensitive.
varname
from the specified workspace
of the server that is attached to handle h
. The workspace
argument can be either base
or global
.
varname
-- the name of the variable whose data is returned
workspace
-- the workspace containing the variable can be either:
base
is the base workspace of the server
global
is the global workspace of the server (see global
for more information about how to access variables in the global workspace).
Note
GetVariable works on all MATLAB data types except sparse arrays, structures, and function handles.
|
Remarks
You can use GetVariable
in place of GetWorkspaceData
, GetFullMatrix
and GetCharArray
to get data stored in workspace variables when you need a result returned explicitly (which might be required by some scripting languages).
Examples
This example assigns a cell array to the variable C1
in the base workspace of the server, and then read it back with GetVariable
, assigning it to a new variable C2
.
MATLAB Client
h = actxserver('matlab.application'); h.PutWorkspaceData('C1', 'base', {25.72, 'hello', rand(4)}); C2 = h.GetVariable('C1','base') C2 = [25.7200] 'hello' [4x4 double]
Visual Basic Client
Dim Matlab As Object Dim Result As String Dim C2 As Object Matlab = CreateObject("matlab.application") Result = Matlab.Execute("C1 = {25.72, 'hello', rand(4)};") C2 = Matlab.GetVariable("C1", "base") MsgBox("Second item in cell array: " & C2(0, 1))
The Visual Basic Client example creates a message box displaying the second element in the cell array, which is the string hello
.
See Also
GetWorkspaceData
, PutWorkspaceData
, GetFullMatrix
, PutFullMatrix
, GetCharArray
, PutCharArray
, Execute
GetFullMatrix | GetWorkspaceData |
© 1994-2005 The MathWorks, Inc.