S-function input ports with different variable dimensions

1 回表示 (過去 30 日間)
Pieter
Pieter 2013 年 2 月 26 日
Hi all,
I am writing a C S-function for Simulink, with two input ports. The width of both ports is set to DYNAMICALLY_SIZED, because the input is a one dimensional vector with 1 or 4 elements. Everything goes well as long as both input signals have the same dimension (1 or 4). However, when the input signals have different dimensions (1 for the first and 4 for the second, or vice versa) the S-function doesn't run. There is an error which says that the input port is vector with 1 element, allthough the signal that goes to the input port is a vector with 4 elements.
Does anyone have an idea on what I am doing wrong, or what might be the solution to this problem?

採用された回答

Kaustubha Govind
Kaustubha Govind 2013 年 2 月 26 日
The documentation suggests that you implement mdlSetInputPortDimensionInfo. Please try adding these lines to your S-function:
#define MDL_SET_INPUT_PORT_DIMENSION_INFO
#if defined(MDL_SET_INPUT_PORT_DIMENSION_INFO) && defined(MATLAB_MEX_FILE)
void mdlSetInputPortDimensionInfo(SimStruct *S, int_T port,
const DimsInfo_T *dimsInfo)
{
if (!ssSetInputPortDimensionInfo(S, port, dimsInfo)) return;
}
#endif

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by