Dynamically sized ports not correct when compiled to s-function

3 views (last 30 days)
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?

Answers (1)

Ashutosh Thakur
Ashutosh Thakur on 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!

Categories

Find more on Block and Blockset Authoring in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!