Dynamically sized ports not correct when compiled to s-function

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

回答(1 个)

Ashutosh Thakur
Ashutosh Thakur 2024-7-16
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!

类别

Help CenterFile Exchange 中查找有关 Block and Blockset Authoring 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by