Main Content

PutCharArray

Character array in Automation server

Synopsis

IDL Method Signature

PutCharArray([in] BSTR varname, [in] BSTR workspace, [in] BSTR string)

MicrosoftVisual BasicClient

PutCharArray(varname As String, workspace As String, string As String)

MATLABClient

PutCharArray(h,'varname','workspace','string')

Description

PutCharArray(h,'varname','workspace','string')stores the character array instringin the specifiedworkspaceof the server attached to handleh, assigning to it the variablevarname.The values forworkspacearebaseorglobal.The function name is case-sensitive.

Examples

expand all

This example shows how to pass character data from a Visual Basic® .NET client to MATLAB®. Create an application with the following code.

typeputchararray.vb
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...") Matlab.PutCharArray("str", "base", _ "He jests at scars that never felt a wound.") MsgBox("In MATLAB, type" & vbCrLf & "str") MsgBox("closing MATLAB window...") Matlab.Quit()

Open the MATLAB window, then clickOk.

In the MATLAB window typestr; MATLAB displays:

str =

He jests at scars that never felt a wound.

ClickOkto close and terminate MATLAB.

This example shows how to pass character data from a Visual Basic® .NET client to MATLAB®. Create an application with the following code.

typeputchararray.vba
Dim Matlab As Object Set Matlab = CreateObject("matlab.application") MsgBox ("MATLAB window created; now open it...") x = Matlab.PutCharArray("str", "base", "He jests at scars that never felt a wound.") MsgBox ("In MATLAB, type" & vbCrLf & "str") MsgBox ("closing MATLAB window...") y = Matlab.Quit()

Open the MATLAB window, then clickOk.

In the MATLAB window typestr; MATLAB displays:

str =

He jests at scars that never felt a wound.

ClickOkto close and terminate MATLAB.

Tips

  • The character array specified in thestringargument can have any dimensions. However,PutCharArray1)×(n列代表的尺寸变化resentation, 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 PutCharArray(h,'Foo','base',chArr) tstArr = GetCharArray(h,'Foo','base') tstArr = adgbehcfk

Version History

Introduced before R2006a