MATLAB: Using S-Function Builder to generate dynamically sized outputs

cs-functions-function buildersimulink

I want to create a C S-Function (ideally using the S-function builder) where one of the output ports is dynamically sized. I would like to be able to set the output port width based on one of the parameters set in my mask dialog, but I don't see any way to do that from within the S-function builder. My parameter is "N" but when I set the "Rows" setting of the Output Ports tab to "N", it complains and refuses to build the S-function. I know I can modify the code the builder generates after the fact using the simulink commands to set the output port width, but that means that each time I need to make a change to this S-function using the builder, I need to go back and hand-edit the generated files to add in the dynamic sizing.
Is what I'm trying to accomplish even possible with the S-function builder, or am I not looking in the right places in the GUI?

Best Answer

According to the documentation, S-Function Builder does not support dynamically-sized inputs/outputs for an S-function with multiple inputs/outputs. However, you should be able to use the Legacy Code Tool to achieve this.