This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

GetVariable

Data from variable in Automation server workspace

Synopsis

IDL 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

MATLAB Client

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

Description

D = GetVariable(h,'varname','workspace') gets data stored in variable varname from the specified workspace of the server attached to handle h and returns it in output argument D. The values for workspace are base or global.

Do not use GetVariable on sparse arrays, structures, or function handles.

If your scripting language requires the explicit return of a result, then use the GetVariable function in place of GetWorkspaceData, GetFullMatrix, or GetCharArray.

Visual Basic .NET Examples

Use a Visual Basic® .NET client to read data from a MATLAB® Automation server. To run examples in products that execute VBA code, see Tips.

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))

Tips

  • To run examples in Microsoft® Office products that execute VBA code, replace the statement:

    MatLab = CreateObject("matlab.application")

    with:

    Set MatLab = CreateObject("matlab.application")
    

    If you need more information, then refer to your VBA product documentation.

Introduced before R2006a