| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
str = h.GetCharArray('varname',
'workspace')
str =
GetCharArray(h, 'varname', 'workspace')
HRESULT GetCharArray([in] BSTR varName, [in] BSTR Workspace, [out, retval] BSTR *mlString)
GetCharArray(varname As String, workspace As String) As String
str = h.GetCharArray('varname', 'workspace') gets the character array stored in varname from the specified workspace of the server attached to handle h and returns it in str. The values for workspace arebase or global.
str = GetCharArray(h, 'varname', 'workspace') is an alternate syntax.
This example uses a MATLAB client.
h = actxserver('matlab.application');
%Assign a string to variable 'str' in the base workspace of the server
h.PutCharArray('str', 'base', ...
'He jests at scars that never felt a wound.');
%Read 'str' back in the client
S = h.GetCharArray('str', 'base')
This example uses a Visual Basic client.
Create the Visual Basic application. Use the MsgBox command to control flow between MATLAB and the application.
Dim Matlab As Object
Dim S As String
Matlab = CreateObject("matlab.application")
MsgBox("In MATLAB, type" & vbCrLf _
& "str='new string';")Open the MATLAB window, then type:
str='new string';
Click Ok.
Try
S = Matlab.GetCharArray("str", "base")
MsgBox("str = " & S)
Catch ex As Exception
MsgBox("You did not set 'str' in MATLAB")
End TryThe Visual Basic MsgBox displays what you typed in MATLAB.
GetVariable | GetWorkspaceData | PutCharArray
![]() | getappdata | getdatasamplesize | ![]() |

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 |