Simulation Toolkit problems with arrays & Matlab

Moderator: Moderators

Simulation Toolkit problems with arrays & Matlab

Postby DR_ » Wed Dec 14, 2022 5:26 pm

Running a simulation with constraints (as MathWorks Matlab parts) and passing in an array is not working for a simple model (and is behaving counterintuitively).

The model calls the same Matlab function twice, and, should produce the same results as described in the comments notated in the model. ultimately, as presented, the input array should get transposed twice, and in the end, "a" should equal "b".

The following is the list of observed issues & questions:
    [1] Setting a single breakpoint "ON EXIT" (or "ON ENTRY") should only be encountered one time; however it is encountered more than twice. (breakpoint is set on the input to either constraint).
    [2] Execution of the simulation takes 3 or more clicks to even get the first solver to run. (See Notes below).
    [3] Execution of the simulation never ends. The value of "b" is never set. (There is nothing blocking the input, and the Matlab console shows the results were solved).
    [4] Execution of the simulation calls the second solver with an empty array in the middle of execution (pin inputs are [1..*] so it should wait for real input).
    [5] The arrays are transposed to be "column vectors" when passed to Matlab regardless of what they were when they were passed to the input pin. (This is confirmed by the inconsistent behavior of the inputs and the associated Matlab outputs seen on the Matlab console output in the simulation toolkit window.

Attached a model with comments added to help demonstrate the odd behavior; hopefully this will help identify what is going wrong.

Note: the Matlab code is also added as a comment in the mdzip as well as the matlab function added to the attachments.
Note: Set Cameo options: Environment:Simulation:"Autostart Active Objects:False" & "Solve After Initialization:False" for debugging does not help isolate the issues.
Note: This is seen using Cameo 2019SP4 with Simulation Toolkit. The issue occurs with both Matlab 2019b and 2021b.
You do not have the required permissions to view the files attached to this post.
DR_
Forum Newbie
Forum Newbie
 
Posts: 2
Posts Rating:0
Joined: Thu Nov 03, 2022 3:04 pm

Re: Simulation Toolkit problems with arrays & Matlab

Postby DR_ » Fri Mar 10, 2023 8:18 am

Still hoping someone can shed some light on this behavior.

Simply put: If I want to pass a single 4 element array to an input pin on a constraint (that is a Matlab/Simulink handoff), the object should NOT get transposed.

Example....

Source data (in Cameo object getting passed into a constraint):
[1, 2, 3, 4]
Note: "expect a single firing on the input pin"

Data seen passed/received into Matlab:
[1,
2,
3,
4]
Note: "firing on input pin is undeterminable/inconsistent"

The transposed data can be seen on the console window.

The workaround we've used is to transpose the input from Matlab. The goal is to use array input & output without extra steps of unnecessary transposing.
DR_
Forum Newbie
Forum Newbie
 
Posts: 2
Posts Rating:0
Joined: Thu Nov 03, 2022 3:04 pm

Re: Simulation Toolkit problems with arrays & Matlab

Postby sherronmira@gmail.com » Fri Mar 10, 2023 10:25 pm

DR_ wrote:Still hoping someone can shed some light on this behavior.

Simply put: If I want to pass a single 4 element array to an input pin on a constraint (that is a Matlab/Simulink handoff), the object should NOT get transposed.

Example....

Source data (in Cameo object getting passed into a constraint ) word wipe:
[1, 2, 3, 4]
Note: "expect a single firing on the input pin"

Data seen passed/received into Matlab:
[1,
2,
3,
4]
Note: "firing on input pin is undeterminable/inconsistent"

The transposed data can be seen on the console window.

The workaround we've used is to transpose the input from Matlab. The goal is to use array input & output without extra steps of unnecessary transposing.

I think this is an optimal solution, I will try it, thanks
sherronmira@gmail.com
Forum Newbie
Forum Newbie
 
Posts: 2
Posts Rating:0
Joined: Thu Aug 25, 2022 8:51 pm


Return to Cameo Simulation Toolkits

Who is online

Users browsing this forum: No registered users and 0 guests

cron