This error usually indicates that Simulink cannot infer the signal dimensions inside the MATLAB Function block, so one or more parameters are being treated as scalars (1 × 1).
By default, the MATLAB Function block inherits the size of every variable unless you explicitly specify it.
- “The default size is –1, which means that the variable inherits its size based on the value of the Scope property.
- If the Scope is Parameter, the variable inherits its size from the associated MATLAB or Simulink parameter.”
- If that associated parameter is a scalar, the inherited size becomes 1 × 1.
When a downstream block (such as Demux) expects a wider vector, the model compilation fails with an underspecified signal-dimension error.
To resolve this issue,you can use the troubleshooting steps:
- Declare parameter sizes explicitly
- Open the MATLAB Function block → Symbols pane > Edit Data.
- For each parameter, set
- Scope = Parameter
- Size = the intended dimension (for example [3 3], [3 1], [1 3]).
2.use Simulink.Parameter objects like:
A = Simulink.Parameter(zeros(3,3));
Then reference A in the MATLAB Function block.
3. Verify compiled sizesTurn on Display > Signals & Ports > Signal Dimensions and update the diagram (Ctrl + D).
You can also query:
get_param('model/MATLAB Function','CompiledPortDimensions')
Once each parameter’s size is defined, the Demux and all downstream blocks will compile successfully.