MATLAB Answers

ActiveX: how to pass a string array to cst in matlab?

8 views (last 30 days)
liang
liang on 13 Nov 2019
Answered: James Tursa on 26 Nov 2019
hi, i'm using the activex interface to control cst(2019) by matlab(2018).matlab works fine as it comes to pass number and sting to cst.
However,when is comes to pass a string array, i get error:
Invalid double parameters array definition (not a valid string array).
I want to know how to pass a string array to cst in matlab.
the matlab code is:
oCSTApp = actxserver('CSTStudio.application');
oProject= oCSTApp.invoke('NewMWS');
Block = invoke(oProject,'Block');
Block.invoke('Reset')
Block.invoke('Type', 'MicrostripCoupledLinesIrregular')
Block.invoke('Name', 'MC2')
Block.invoke('SetIntegerProperty','Number Of Lines', 4)
sWidth={"0.5";"1.1";"2.2";"3.3"}
Block.invoke('SetDoubleArrayProperty','Widths', sWidth)(will get error here!)
the VBA code is :
'Create a block
With Block
.Reset
.Type ("MicrostripCoupledLinesIrregular")
.Name ("MC2")
Dim sWidth(0 To 3) As String
sWidth(0) = "0.5"
sWidth(1) = "1.1"
sWidth(2) = "2.2"
sWidth(3) = "3.3"
.SetIntegerProperty("Number Of Lines", 4)
.SetDoubleArrayProperty("Widths", sWidth)
.Position(51050, 51000)
.Create
End With

  5 Comments

Show 2 older comments
Johan
Johan on 25 Nov 2019
Did you get this to work? I have the same problem.
dpb
dpb on 26 Nov 2019
I'd guess your only hope will be thru MEX and a C-style string (null terminated char() array)
What if you try a char() array that mimics such in MATLAB?

Sign in to comment.

Answers (2)

Steven Lord
Steven Lord on 13 Nov 2019
sWidth={"0.5";"1.1";"2.2";"3.3"}
The error message is accurate in that sWidth is not a string array. It is a cell array whose cells contain string arrays. You could try passing an actual string array, though I'm not certain exactly how string interacts with COM objects.
sWidth=["0.5";"1.1";"2.2";"3.3"]

  1 Comment

liang
liang on 14 Nov 2019
I have already tried this and still got error:
Invalid double parameters array definition (not a valid string array).

Sign in to comment.


James Tursa
James Tursa on 26 Nov 2019
Couple of things you might also try
sWidth={'0.5';'1.1';'2.2';'3.3'};
or
sWidth={'0.5';'1.1';'2.2';'3.3'};
sWidth = cellfun(@(x)[uint8(x) uint8(0)],sWidth,'uni',false);

  0 Comments

Sign in to comment.

Sign in to answer this question.

Products


Release

R2018a