Why do I receive an error message when I use the ssSetInputPortWidth macro in my C MEX S-function that takes frame-based inputs?
I want to design a C MEX S-function that has frame-based inputs and outputs. Besides, both input and output sizes need to be dynamically sized. My mdlInitializeSizes callback reads as follows:
static void mdlInitializeSizes(SimStruct *S){ // Input port if (!ssSetNumInputPorts(S, NUM_IMPORT)) return; ssSetInputPortFrameData(S, INPORT, FRAME_INHERITED); ssSetInputPortComplexSignal(S, INPORT, COMPLEX_NO); ssSetInputPortWidth(S, INPORT, DYNAMICALLY_SIZED); ssSetInputPortDirectFeedThrough(S, INPORT, TRUE); …… // Outputs if (!ssSetNumOutputPorts(S, NUM_OUTPORT)) return; ssSetOutputPortFrameData(S, OUTPORT, FRAME_INHERITED); ssSetOutputPortComplexSignal(S, OUTPORT, COMPLEX_NO); ssSetOutputPortWidth(S, OUTPORT, DYNAMICALLY_SIZED); ……}
After I compiled my s-function and ran my model, I received the following error message:
Cannot set port 0 of block 'untitled/S-Function' to have one dimension when this port is set to be frame-based. For a frame-based port, the number of dimensions should be greater than 1
Best Answer