How do I store user data into a Simulink block?

8 views (last 30 days)
How do I store user data into a Simulink block?
For example, I have a large data set I want to associate with a Simulink block such as the n-D Look-Up. When I use the SET_PARAM function to set the data set, part of the data is truncated when I re-open the model later.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 14 Dec 2015
There is a size constraint on how many characters can fit into a string block parameter. To work around this issue, try to use the USERDATA parameter into the MDL file as a MAT-file.
For example to associate table_values into the n-D Lookup Table block, try the following:
1. Click the n-D Lookup Table block and type the following at the MATLAB command prompt:
 
set_param(gcb,'UserDataPersistent','on')
set_param(gcb,'UserData', table_values)
where table_values is the actual table values of double data-type.
2. Double click the n-D Lookup Table and enter table_values for the "Table data" parameter.
3. Right click the n-D Lookup Table block and select "Block properties..."
4. Click the "Callbacks" tab and place the following code in the "LoadFcn" callback function:
 
table_values = get_param(gcb,'UserData')

More Answers (0)

Categories

Find more on Nonlinearity in Help Center and File Exchange

Products


Release

R13SP1

Community Treasure Hunt

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

Start Hunting!