How to generate lookup table data into a custom structure?
12 views (last 30 days)
Show older comments
How to generate lookup table data into a custom structure?
When generate code, the input data of several lookup tables(or my own S-Functions) are all
data in different struct. Besides, i want to put different struct into different memory
section.
e.g. I create my own S-function "mylookup1D", which has XData and YData. Then i put two
mylookup1D in a model "test" and input XData and Ydata value. After code generation,
mylookup1D_XData, mylookup1D_YData, mylookup1D1_XData, mylookup1D1_YData are all generated into
struct test_ConstP{}. But i want to put mylookup1D_XData, mylookup1D_YData in one struct and
mylookup1D1_XData, mylookup1D1_YData in another.
How to do this???
Thanks a lot!
0 Comments
Answers (1)
TAB
on 20 Mar 2012
Instead of defoning look-up table array directly in the Look-up table block itself, define them as Simulink.Parameter object in base workspace. Use these parameters in look0up table block.
Now define the storage class of parameter as Custom -> struct. For example your parameters are mylookup1D_XData & mylookup1D_YData. Declare these parametrs in base workspace as
mylookup1D_XData = Simulink.Signal;
mylookup1D_XData.RTWInfo.StorageClass = 'Custom';
mylookup1D_XData.RTWInfo.CustomStorageClass = 'Struct';
mylookup1D_XData.RTWInfo.CustomAttributes.StructName = MyStruct1;
mylookup1D_YData = Simulink.Signal;
mylookup1D_YData.RTWInfo.StorageClass = 'Custom';
mylookup1D_YData.RTWInfo.CustomStorageClass = 'Struct';
mylookup1D_YData.RTWInfo.CustomAttributes.StructName = MyStruct1;
In this way mylookup1D_XData & mylookup1D_YData will be generated in MyStruct1. Similarly you can create another struct for other 2 parametrs.
[EDITED][20-March-2012 8:28 pm]
TLC files for look-up table (look_up.tlc, lookup2d.tlc, lookup_nd.tlc) are available in
MATLAB_ROOT\R2010b\rtw\c\tlc\blocks
3 Comments
TAB
on 20 Mar 2012
Modifying tlc file is always an option for customizing the code generation, but modifying tlc of inbuilt simulink block is strongly not recommended. If you are modifying tlc make sure to back up original files.
---------
TLC files for look-up table (look_up.tlc, lookup2d.tlc, lookup_nd.tlc) are available in
MATLAB_ROOT\R2010b\rtw\c\tlc\blocks
---------
Another option is, you can write your own s-function for look-up & implement it's inlining tlc as per your requirement.
See Also
Categories
Find more on Target Language Compiler in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!