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.

PutWorkspaceData

Data in Automation server workspace

Synopsis

IDL Method Signature

PutWorkspaceData([in] BSTR varname, [in] BSTR workspace,
[in] VARIANT data)

Microsoft Visual Basic Client

PutWorkspaceData(varname As String, workspace As String,
data As Object)

MATLAB Client

PutWorkspaceData(h,'varname','workspace',data)

Description

PutWorkspaceData(h,'varname','workspace',data) stores data in the workspace of the server attached to handle h and assigns it to varname. The values for workspace are base or global.

Use PutWorkspaceData to pass numeric and character array data respectively to the server. Do not use PutWorkspaceData on sparse arrays, structures, or function handles. Use the Execute method for these data types.

The GetWorkspaceData and PutWorkspaceData functions pass numeric data as a variant data type. These functions are especially useful for VBScript clients as VBScript does not support the safearray data type used by GetFullMatrix and PutFullMatrix.

Visual Basic .NET Examples

Create an array in a Visual Basic® .NET client and put it in the base workspace of the MATLAB® Automation server. To run examples in products that execute VBA code, see Tips.

  1. Create the Visual Basic application. Use the MsgBox command to control flow between MATLAB and the application:

    Dim Matlab As Object
    Dim data(6) As Double
    Dim i As Integer
    MatLab = CreateObject("matlab.application")
    For i = 0 To 6
       data(i)  = i * 15
    Next i
    MatLab.PutWorkspaceData("A","base",data)
    MsgBox("In MATLAB, type" & vbCrLf & "A")
  2. Open the MATLAB window and type A. MATLAB displays:

    A =
         0    15    30    45    60    75    90
  3. Click OK to close and terminate MATLAB.

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