Change dimension of tunable parameter for executable with Simulink model

12 次查看(过去 30 天)
Hi, I want to deploy a Simulink Model (invoked by a script). It should behave on variables loaded from a mat-file that can be edited. I tried this with the Simulink Compiler toolbox, and it already works with tunable parameters and external inputs for variables whose dimensions does not change.
Now I would like the model to contain a 1-D lookup table whose behavior is changeable after creating the executable. The thing is that the length of the table data and the breakpoints should be changeable as well and not just the values.
Here is the code of the script that invokes the model:
%#exclude modelParams.mat
load('modelParams.mat');
simIn = Simulink.SimulationInput('model');
simIn = Simulink.compiler.configureForDeployment(simIn);
simIn = simIn.setVariable('slop', slop);
simIn = simIn.setVariable('dist', dist);
simOut = sim(simIn);
simResult = [simOut.tout, simOut.result];
save('simResult.mat','simResult');
The mat-file contains the two variables slop (defines table data) and dist (defines breakpoints). The Simulink model is named model here. Both the mat-file and an example model are attached.
Trying to change the dimensions of the variables in the mat-file, I received the error:
The dimensions [1 3] of the value specified for the tunable variable 'slop' does not match the expected dimensions [1 2]
I would like to know if it is possible to change the dimensions of the lookup table data and breakpoints after deployment, either with the Simulink compiler or another MathWorks product.
Thanks in advance

回答(1 个)

Ayush
Ayush 2023-9-27
Hey Kevin,
I understand that you want to know about changing the dimensions of a lookup table's data and breakpoints after deploying a Simulink model. You want to know if it's possible to modify the dimensions of the lookup table, including the length of the table data and breakpoints, after creating an executable using the Simulink Compiler toolbox.
When it comes to changing the dimensions of lookup table data and breakpoints after deployment using the Simulink Compiler or other MathWorks products, it can be challenging. The dimensions of lookup tables typically affect the generated code structure and behavior, which are usually fixed during compilation.
However, there is a feature called "Support tunable size" available in Simulink for lookup tables that allows you to work with a smaller range of active breakpoints within the fixed-size arrays. This feature is only available for code generation and can be enabled by selecting the "Support tunable size" checkbox in the Advanced tab of the Simulink.LookupTable property dialog box.
By enabling this feature, the generated C/C++ code will include a tunable size variable. You can change the value of this variable between compile runs or during program execution by writing into its memory location. This way, you can effectively tune or calibrate the lookup table without the need to resize the arrays and regenerate the code.
To learn more about "BreakPoint and Table size features in Lookup table" , refer to the MathWorks documentation link below:
Hope this helps !
Regards,
Ayush Goyal

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by