Simulink block with dynamic input port width and fix output port width

7 visualizaciones (últimos 30 días)
Rob
Rob el 30 de Jun. de 2014
Respondida: Kaustubha Govind el 10 de Jul. de 2014
Hi, I'd like to have a custom Simulink block that accepts a 1-D signal of any positive length and outputs a 1-D vector of a fixed size of 256. I created a block with the Simulink block Builder and changed only the macro INPUT_0_WIDTH to -1 and the OUTPUT_0_WIDTH to 256.
My test scenario is a constant source that has the value [97 97 98 102 110 99 120] and is attached to my S-Function. The output port of my S-Function is connected to a Display sink.
Now when I start the simulation, it throws an error because of invalid input port width of my S-Function. The error messag is:
Error in port widths or dimensions. Invalid dimension has been specified for input port 1 of 'stringbuilder_test/S-Function'.
I also tried to use the DYNAMICALLY_SIZED constant instead of -1.
Edit: I tried to decrease the output width to the number of elements in the input signal and it worked. Then I increased the number of input elements equivalent to the width of my output width and it worked. It seems these two values are directly linked. Then I saw I set the direct feed-through flag to 1, so I set it to 0, but it did not have any effect.
Do you have any suggestions please?
I pasted the whole code here: http://codepaste.net/uqsw1n for reference

Respuestas (1)

Kaustubha Govind
Kaustubha Govind el 10 de Jul. de 2014
According to the documentation for ssSetInputPortWidth:
"If the width is dynamically sized, the S-function must provide mdlSetInputPortDimensionInfo and mdlSetDefaultPortDimensionInfo methods to enable the signal dimensions to be set correctly during signal propagation."
Perhaps if you implement those methods, you can achieve what you need?

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by