Main Content

GetVariable

自动化的变量数据服务器的工作区

Synopsis

IDL Method Signature

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

MicrosoftVisual BasicClient

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

MATLABClient

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

Description

D = GetVariable(h,'varname','workspace')gets data stored in variablevarnamefrom the specifiedworkspaceof the server attached to handlehand returns it in output argumentD.The values forworkspacearebaseorglobal.

DonotuseGetVariableon sparse arrays, structures, or function handles.

If your scripting language requires the explicit return of a result, then use theGetVariablefunction in place ofGetWorkspaceData,GetFullMatrix, orGetCharArray.

Examples

expand all

This example shows how to read a cell array from a MATLAB Automation server.

typegetvariable.vb
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))

This example shows how to read a cell array from a MATLAB Automation server.

typegetvariable.vba
Dim Matlab As Object Dim Result As String Dim C2 As Variant Set 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))

Version History

Introduced before R2006a