Why are my MATLAB Function block arguments being inferred as variable size?

27 views (last 30 days)
Hi,
I am running into the following error message with a Simulink Model using a MATLAB Function Block.
Data 'out' is inferred as a variable size matrix, while its properties in the Model Explorer specify its size as inherited or fixed. Please check the 'Variable Size' check box and specify the upper bounds in the size field.
It is not clear to me why the matrix is being inferred as variable size. Inside, the MATLAB Function Block, I define out to have a certain, fixed size corresponding to the values of two other parameters defined in the MATLAB Function block, as follows:
>> out = zeros(X,Y);
X and Y are defined as parameters within the MATLAB Function block, but they do not change during the simulation.
Why is the array variable-sized, and how do I resolve this??

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 13 Jan 2020
In this particular case, variables X and Y were defined as Tunable parameters within the MATLAB Function block. This leads to Simulink interpreting the array as variable sized because X and Y could theoretically change during the simulation, even though their values clearly do not change here.
To resolve this, there are two potential solutions:
  1. Set X and Y to be non-tunable using the 'Edit Data' option from within the MATLAB Function Block.
  2. Set 'out' to variable-size as suggested by the message. In most cases this will resolve the warning straight away, but there may be other limitations that cause warnings/errors elsewhere in the model, so in general this should be recommended second.
Other users have encountered the same thing here:

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!