How to define matrices generated in Stateflow as Fixed size?

18 views (last 30 days)
Alex
Alex on 13 Jan 2025 at 14:56
Edited: Alex on 16 Jan 2025 at 8:19
Hi,
I have had a look around the forum and while there are some similar questions to mine I simply am not understanding where I am going wrong.
Below is my top level design:
with the sub-level looking like this:
the aim for this code is to take two matrices, split them up in to smaller matrices and output complementary slices each time step.
My code works in this sense but trying to use it with further blocks causes this error: "This input port expects a fixed-size mode. The variable-size mode originates from 'controller/Subsystem/Chart'. Examine the configurations of 'controller/Subsystem/Matrix Multiply' for one of the following scenarios: 1) the block does not support variable-size signals; 2) the block supports variable-size signals but needs to be configured for them."
When not setting Slice A or B to variable size I get this error: "'slice_B' is inferred as a variable-size matrix, but its size is specified as inherited or fixed. Verify 'slice_B' is defined in terms of non-tunable parameters, or select the 'Variable Size' check box and specify the upper bounds in the Size box."
What can I do to fix this issue? Thanks in advance!

Answers (1)

Githin George
Githin George on 15 Jan 2025 at 11:12
Hi Alex,
I understand that you are facing 2 issues here:
  1. If you specify the corresponding data variables as “variable-size” then the “Matrix Multiply” block is throwing error since it is unsupported case.
  2. If you specify the signals as “fixed-size”, then the Stateflow chart is throwing error mentioning that the variable “slice_B” is inferred to be variable-size matrix.
I think your best bet is to focus on the 2nd issue and I suspect that the root cause is assignment of “slice_B” with the slightly complex indexing. I think this is causing to Simulink to resolve/infer “slice_B” to be a variable-size matrix. One way to test this out is to use “for-loops” or “indexed-assignment” into the variable “slice_B” to avoid the complex 2-D indexing with the variables “sBf” and “sBI”.
Also, double check whether your computations are altering the size of “slice_B” since there are many assignment expressions.
If you are facing any issues, provide a reproduction model so that I can give it a try as well.
  1 Comment
Alex
Alex on 16 Jan 2025 at 8:19
Edited: Alex on 16 Jan 2025 at 8:19
I managed to figure it out. I had to define the slice_A and slice_B matrices before entering the first step as empty matrices with fixed size values. Thanks for your help!

Sign in to comment.

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!