How to generate lookup table data into a custom structure?
이전 댓글 표시
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!
답변 (1개)
TAB
2012년 3월 20일
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
Peng
2012년 3월 20일
TAB
2012년 3월 20일
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.
Peng
2012년 3월 21일
카테고리
도움말 센터 및 File Exchange에서 Target Language Compiler에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!