| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
h.PutWorkspaceData('varname', 'workspace',
data)
PutWorkspaceData(h,
'varname', 'workspace', data)
PutWorkspaceData([in] BSTR varname, [in] BSTR workspace, [in] VARIANT data)
PutWorkspaceData(varname As String, workspace As String, data As Object)
h.PutWorkspaceData('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.
PutWorkspaceData(h, 'varname', 'workspace', data) is an alternate syntax.
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.
Create an array in a MATLAB client and put it in the base workspace of the MATLAB Automation server:
h = actxserver('matlab.application');
for i = 0:6
data(i+1) = i * 15;
end
h.PutWorkspaceData('A', 'base', data)
Create an array in a Visual Basic client and put it in the base workspace of the MATLAB Automation server:
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")Open the MATLAB window and type A. MATLAB displays:
A =
0 15 30 45 60 75 90Click Ok to close and terminate MATLAB.
Execute | GetWorkspaceData | PutCharArray | PutFullMatrix
![]() | PutFullMatrix | pwd | ![]() |

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 |