Dynamically sized IO ports in simulink
Mostrar comentarios más antiguos
Hi,
I am working on a C-MEX s-function, which has 2 inputs and 1 output. All of the i/o ports are dynamically sized. The output port should always have the same size with the second input port.
Here are some fragments of my code.
/* ... */
static void mdlInitializeSizes(SimStruct *S)
{
... // Set two input and one output ports to dynamically sized
}
#if defined(MATLAB_MEX_FILE)
#define MDL_SET_INPUT_PORT_WIDTH
static void mdlSetInputPortWidth(SimStruct *S, int_T port, int_T inputPortWidth)
{
ssSetInputPortWidth(S, port, inputPortWidth);
/* This is very likely wrong */
if (1 == port) {
ssSetOutputPortWidth(S, port, inputPortWidth);
}
}
#define MDL_SET_OUTPUT_PORT_WIDTH
static void mdlSetOutputPortWidth(/* ... */)
{
/* I don't know how to set here */
}
static void mdlSetDefaultPortDimensionInfo(SimStruct *S)
{
ssSetInputPortWidth(S, 0, 10);
ssSetInputPortWidth(S, 1, 3);
ssSetOutputPortWidth(S, 0, 3);
}
#endif
/* ... */
It could be compiled with no error, but everytime I run the test simulink model with this s-function in it, MATLAB crashes.
Could someone tell me how to solve this, please?
Thanks in advance.
Ben
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Block and Blockset Authoring en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!