| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
h.PutCharArray('varname', 'workspace', 'string')
PutCharArray(h, 'varname', 'workspace', 'string')
invoke(h, 'PutCharArray', 'varname', 'workspace', 'string')PutCharArray([in] BSTR varname, [in] BSTR workspace,
[in] BSTR string)
PutCharArray(varname As String, workspace As String,
string As String)
PutCharArray stores the character array in string in the specified workspace of the server attached to handle h, assigning to it the variable varname. The workspace argument can be either base or global.
The character array specified in the string argument can have any dimensions. However, PutCharArray changes the dimensions to a 1–by-n column-wise representation, where n is the number of characters in the array. Executing the following commands in MATLAB illustrates this behavior:
h = actxserver('matlab.application');
chArr = ['abc'; 'def'; 'ghk']
chArr =
abc
def
ghk
h.PutCharArray('Foo', 'base', chArr)
tstArr = h.GetCharArray('Foo', 'base')
tstArr =
adgbehcfk Server function names, like PutCharArray, are case sensitive when using the dot notation syntax shown in the Syntax section.
There is no difference in the operation of the three syntaxes shown above for the MATLAB client.
Store string str in the base workspace of the server using PutCharArray.
h = actxserver('matlab.application');
h.PutCharArray('str', 'base', ...
'He jests at scars that never felt a wound.')
S = h.GetCharArray('str', 'base')
S =
He jests at scars that never felt a wound.This example uses the Visual Basic MsgBox command to control flow between MATLAB and the Visual Basic Client.
Dim Matlab As Object
Try
Matlab = GetObject(, "matlab.application")
Catch e As Exception
Matlab = CreateObject("matlab.application")
End Try
MsgBox("MATLAB window created; now open it...")
Open the MATLAB window, then click Ok.
Matlab.PutCharArray("str", "base", _
"He jests at scars that never felt a wound.")
MsgBox("In MATLAB, type" & vbCrLf _
& "str")
In the MATLAB window type str; MATLAB displays:
str = He jests at scars that never felt a wound.
Click Ok.
MsgBox("closing MATLAB window...")
Click Ok to close and terminate MATLAB.
Matlab.Quit()
GetCharArray, PutWorkspaceData, GetWorkspaceData, Execute
![]() | publish | PutFullMatrix | ![]() |

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 |