force scalar signal to be a 1D array

8 vues (au cours des 30 derniers jours)
Aditya Kumar
Aditya Kumar le 18 Mai 2017
Réponse apportée : Suhan le 24 Mai 2017
I have a use-case, where I need to force a scalar input signal, say u1 to a subystem test1 in a Simulink model, to be treated as a 1D array with 1 element. In particular, when I generate C-code from test1, instead of the input being declared as "static real_T test1_U_u1;", I need it to be declared as "static real_T test1_U_u1[1];". Is there a way to do this either in Simulink and/or via some settings for code generation? Please let me know at the earliest. I am using R2015b with Simulink, Matlab and embedded coders. Thanks. -Aditya

Réponses (1)

Suhan
Suhan le 24 Mai 2017
Currently, this is not possible in Simulink. However, one alternative to consider depending on the use case is to use a custom storage class for the variable and set it to "ImportedExternPointer". A example of this can be found in the documentation here: http://www.mathworks.com/help/ecoder/ug/pointers-for-signals.html?s_tid=srchtitle
Another alternative which is much simpler is to specify Variable-size within a subsystem Inport. Select support for variable-sized signal in the signal attributes and make sure to enter a maximum dimension for the vector and uncheck the interpolate data option. This will generate variable sized assignments.

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by