Page 1 of 1

Passing Arrays to Matlab

PostPosted: Thu Jan 24, 2019 11:16 am

I would like to use the interpolation functions of MATLAB with CST. I am able to pass real number value properties to MATLAB and retrieve the results. I now want to pass a value property containing a real number array to MATLAB. How do I do this. I have tried using multiplicity, but CST only passes the first item in the "array" to MATLAB.

From CST I want to store a real number array [2, 5, 7, 3, 5, etc.] and then pass that array to MATLAB for interpolation. Right now I can brute force it by treating it as a string and then converting it in MATLAB to a real number array, but there has to be a more elegant way.



Re: Passing Arrays to Matlab

PostPosted: Tue Dec 03, 2019 2:17 am
by JuS
Hello Grant,

if you are using a fixed number of values, I would recommend the following approach:

Create yout own value type "vector", with n number of real values v_i to v_n:
1. Create new value type
2. to go "Attributes" tab and add n number of atributes
3. Apply stereotype "ValueProperty" to each as well as "Type" (Real, tec.) (green markings in picture 1)

To access the values, I had to find them:
1. right click on v:vektor -> edit compartments -> move all wanted values to the "selected"-side. This displays "v1" and "v2" as shown in picture 1.
2. Connect "v1" and "v2" to the matlab function. In my case "setDataVector", without an output. (see first picture)

I hope this helps.
If you find a way to directly move "v:vector" into matlab, please let me know.
I need to move something equal to a matlab structure between CSM and a matlab function.

Kind regards,

Re: Passing Arrays to Matlab

PostPosted: Thu Jul 15, 2021 4:22 pm
Some more information from the OP would have been great, but at this point it's 2.5 years ago... I have had luck with setting the multiplicity of the input pin to an Opaque Action, or a Call Behavior Action calling a Function Behavior, that implements a MATLAB script in the Body.