How to make use of custom storage classes for Look up tables?
2 views (last 30 days)
Show older comments
MathWorks Support Team
on 27 Feb 2019
Answered: MathWorks Support Team
on 21 Mar 2019
How to make use of custom storage classes for Look up tables?
Accepted Answer
MathWorks Support Team
on 27 Feb 2019
Firstly,
Create an LUT Object as per the link: https://www.mathworks.com/help/simulink/slref/simulink.lookuptable-class.html
>> LUTObj = Simulink.LookupTable;
>> LUTObj.Table.Value = [1.1 2.2 3.3 4.4 5.5];
>> LUTObj.Breakpoints(1).Value = [-2 -1 0 1 2];
>> LUTObj.StructTypeInfo.Name = 'myLUTStruct';
The above creates an Look-Up Table object in the base workspace. You can double click on it from the workspace in order to update the Storage Class.
Then, in the model attached there is a Look-up table.
In the block parameters, under Data Specification specify the "Look-up Table object" the name as "LUTObj" created previously and then update the model (Ctrl+D).
Once this is done, you can navigate to the Model Data Editor-> Parameters-> Code tab and then make changes to the Storage Class of the Look-up table object.
You can select the storage class based on your requirements. Once you do that, you can generate code for the same and note the changes in how the Look up Table object is reflected in the code.
To understand the different storage classes available, review the links below:
1) https://www.mathworks.com/help/rtw/ug/choose-a-built-in-storage-class-for-controlling-data-representation-in-the-generated-code.html
2) https://www.mathworks.com/help/rtw/ug/how-generated-code-stores-internal-signal-state-and-parameter-data.html
3) https://www.mathworks.com/help/ecoder/examples/configure-data-interface-by-applying-custom-storage-classes.html
See the attached files for an example of using the Simulink.LookupTable object with the Struct custom storage class.
0 Comments
More Answers (0)
See Also
Categories
Find more on Nonlinearity 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!