function output dimension in Simulink

13 vues (au cours des 30 derniers jours)
Stefano Di Benedetto
Stefano Di Benedetto le 1 Sep 2018
Hi everybody, i'm using a matlab function in Simulink in order to solve an optimization problem: to this purpose, i have as inputs in my function both matrix and constant values. In the function I extract a matrix index (corresponding to a minimum value) and than i use this index to get a value from a vector, so that i should have my scalar output value. Now, if I run the function code by command windows, it works well and give as output a scalar value, but if i run the code inside a Simulink function i have this error:
"Data 'T2_target' 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"
(where T2_targer is my output);
I can't understand this kind of error.
Thank you

Réponse acceptée

Naman Chaturvedi
Naman Chaturvedi le 4 Sep 2018
Modifié(e) : Naman Chaturvedi le 4 Sep 2018
Hi Stefano,
The error occurs because your MATLAB function provides the output of a variable-size but, as defined in the Model Explorer, it is of fixed size, or it inherits its size. You can simply take care of this error by checking the "Variable Size" checkbox in the model explorer and specify the upper bound. To do so, open your MATLAB function in the editor, then select EDITOR->Edit data, select output variable, check the variable size checkbox and specify the limit range of your output.
HTH

Plus de réponses (0)

Catégories

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

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by