How to define matrices generated in Stateflow as Fixed size?

3 次查看(过去 30 天)
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!

回答(1 个)

Githin George
Githin George 2025-1-15
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 个评论
Alex
Alex 2025-1-16
编辑:Alex 2025-1-16
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!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Decision Logic 的更多信息

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by