Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

GetVariable - Data from variable in Automation server workspace

Synopsis

MATLAB Client

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

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

Description

D = h.GetVariable('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.

D = GetVariable(h, 'varname', 'workspace') is an alternate syntax.

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

If your scripting language requires a result be returned explicitly, use the GetVariable function in place of GetWorkspaceData, GetFullMatrix or GetCharArray.

Examples

Use a MATLAB client to read data from a MATLAB Automation server:

%Create the MATLAB server
h = actxserver('matlab.application');
%Create variable C1 in the base workspace of the server
h.PutWorkspaceData('C1', 'base', {25.72, 'hello', rand(4)});
%The client reads the data 
C2 = h.GetVariable('C1','base')
 

Use a Visual Basic client to read data from a MATLAB Automation server:

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

See Also

Execute | GetCharArray | GetFullMatrix | GetWorkspaceData

How To

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

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