force scalar signal to be a 1D array
8 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Suhan
on 24 May 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.
0 Comments
See Also
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!