Why am I getting an error saying Simulink cannot determine sizes for a MATLAB Function block? 

246 views (last 30 days)
Why am I getting an error saying Simulink cannot determine sizes for a MATLAB Function block?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 13 Jan 2020
Edited: MathWorks Support Team on 13 Jan 2020
The Diagnostic Viewer may show several different error messages referring to a MATLAB Functon block in your model:
(1) Simulink cannot determine sizes and/or types of the outputs for block <blockpath> due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs.
(2) Simulink does not have enough information to determine output sizes for this block. If you think the errors below are inaccurate, try specifying types for the block inputs and/or sizes for the block outputs.
(3) Error in default port dimensions function of S-function <blockpath>. This function does not fully set the dimensions of output port <portnumber>
This typically happens due to:
(a) some errors inside the code of the MATLAB Function block itself, which are effectively masked by higher level errors in the model caused by an inability to determine the block port characteristics. There may be additional messages following this which indicate an underlying problem in the code, but not always.
(b) several MATLAB Function blocks in a feedback loop where each contains code where the output data size and type depend on that of the input and vice versa. Essentially, this is a sort of analogous situation to a numerical algebraic loop, but with signal characteristics.
In either case the approach is the same:
(1) Open the MATLAB Function Block which reported the error, and select Edit Data on the Editor tab. Alternatively select the block in the Model Explorer ( CTRL+H ).
(2) Select each variable corresponding to Input and Output ports, and in the Size edit box, specify the correct dimensions. (The default is -1 or 'inherited', meaning automatically determined. However, this is what cannot be automatically determined in these scenarios.)
(3) Steps (1) and (2) may need to be repeated for other MATLAB Function Blocks in the model if they subsequently generate similar errors now.
In scenario (a) where the MATLAB Function Block code had some underlying issue(s), this should eliminate the error messages about port dimensions and allow Simulink to more accurately determine and report the underlying issue(s) within the code for the MATLAB Function block itself.
In scenario (b) with multiple MATLAB Function Blocks in a feedback loop, this should provide enough information for Simulink to determine the signal dimensions.
Overall, a similar approach can be taken for other port characteristic error messages for MATLAB Function blocks, e.g. data type.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!