force scalar signal to be a 1D array

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

回答(1 个)

Suhan
Suhan 2017-5-24
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.

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by