Dynamically sized ports not correct when compiled to s-function

2 Ansichten (letzte 30 Tage)
Robrecht
Robrecht am 29 Mai 2024
Beantwortet: Ashutosh Thakur am 16 Jul. 2024
Hello,
I have created a simple model with just one block. The input and output port dimension are configured to be inherited. When i use this model in another model i have no issues. But when i compile the model to an S-funcion block, the generated S-funcion always uses a 1-dimensional vetcor with a single element as its dimension even when i connect a multidimensional signal. This should not be the case i think.
What could be the reason for this issue?

Antworten (1)

Ashutosh Thakur
Ashutosh Thakur am 16 Jul. 2024
Hi Robrecht,
It seems like the dimensions of the signals are not being propagated correctly when you compile the model to the S-Function block. This behavior might be due to the way the S-Function is implemented to handle variable dimensions.
You should check that the mdlInitializeSizes function has specified the DYNAMICALLY_SIZED attribute. The input and output ports can be set to this attribute to tell the Simulink engine to size them dynamically. You can refer to the following documentation for more information: https://www.mathworks.com/help/simulink/sfg/mdlinitializesizes.html.
Additionally, you can look into different functions such as ssSetInputPortMatrixDimensions and ssSetInputPortDimensionInfo. These functions help in setting the dimensions of the input and output ports dynamically. Here are some useful documentation links for more information and examples:
I hope this information helps you!

Kategorien

Mehr zu Block and Blockset Authoring finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by