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

27 vues (au cours des 30 derniers jours)
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??

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 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:

Plus de réponses (0)

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by