function output dimension in Simulink

12 次查看(过去 30 天)
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

采纳的回答

Naman Chaturvedi
Naman Chaturvedi 2018-9-4
编辑:Naman Chaturvedi 2018-9-4
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by