GetVariable - Get data from variable in server workspace

Synopsis

MATLAB Client

D = h.GetVariable('varname', 'workspace')
D = GetVariable(h, 'varname', 'workspace')
D = invoke(h, 'GetVariable', 'varname', 'workspace')

Method Signature

HRESULT GetVariable([in] BSTR varname, [in] BSTR workspace, 
[out, retval] VARIANT* pdata)

Microsoft Visual Basic Client

GetVariable(varname As String, workspace As String) As Object

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:

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 .NET 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

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS