MATLAB: Does Embedded MATLAB Function block not inherit the input port size in Simulink 6.0 (R14) and later

embeddedemffeedbackfunctioninheritedinputMATLABportsimulinksize;width

I use the Embedded MATLAB Function block in my model. I also have a direct feedback from the outputs of this block to its inputs. When I try to set the input port size to be inherited, I get the following error:
Embedded MATLAB Interface Error: 'fuel_migration/getWeight - While Iterator Subsystem/call_getWeight - EMF/ SFunction ' cannot use 'set default dimension function'

Best Answer

This is intended behavior in Simulilnk 6.0 (R14) and later, when the Embedded MATLAB Function block has a direct feedback connection.
In this case, the size of the input to the Embedded MATLAB Function block depends on the size of the output from the same Embedded MATLAB Function block. Therefore, the size must be specified somewhere to break the loop. To handle this case, Simulink defaults the signal dimension to a scalar. You can verify this in the Model Explorer in the "compiled size" field for the input signal.
This behavior is expected because graphical loops without size/type specifications can potentially cause errors in the propagation algorithm and should be avoided.