Error using main_maglev_SFC_OBS (line 153) Compilation of model 'simu_maglev_SFC_OBS' failed while trying to resolve underspecified signal dimensions.

21 ビュー (過去 30 日間)
Daniel
Daniel 2025 年 11 月 3 日 0:35
回答済み: Abhipsa 2025 年 11 月 5 日 4:50
Getting an error where the function block thinks all my parameters are 1x1 but they are not.
Error using main_maglev_SFC_OBS (line 153)
Compilation of model '
simu_maglev_SFC_OBS' failed while trying to
resolve underspecified signal dimensions.
Suggested Actions:
Enable 'warning' or 'error' diagnostics for the list of underspecified signal dimensions. -
Open
Caused by:
Error using
main_maglev_SFC_OBS (line 153)
Invalid setting for input port dimensions of
'
simu_maglev_SFC_OBS/Demux'. The dimensions are being set to 1. This
is not valid because the total number of input and output elements
are not the same
Error using
main_maglev_SFC_OBS (line 153)
Error in port widths or dimensions. '
Output Port 2' of
'
simu_maglev_SFC_OBS/MATLAB Function' is a one dimensional vector
with 1 elements.
I feel like I have tried everything.

回答 (1 件)

Abhipsa
Abhipsa 2025 年 11 月 5 日 4:50
Hello @Daniel,
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:
  1. 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));
A.Value = yourA; % keeps 3×3 size fixed
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.

カテゴリ

Help Center および File ExchangeSignal Routing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by