Clear Filters
Clear Filters

how to connect simulink parameter with struct elements for standalone program

1 view (last 30 days)
Simulink stand alone program, app designer, app calling simulink exe with different parameter
Goal is the development of a stand alone program based on a simulink modell and the possibility to change parameters of the modell with app designer.
The present solution is that I create the Simulink modell with parameter names as Ks11, Ts11 for amplification and time constant.
Then in simulink with “view -> modell explorer the variables are created, values are defined with datatype double.
The parameters for code generation are set, e.q. parameter behavior is set as tunable.
Solver as fixed step with automatic solver selection or with one of the possible solver.
With
set_param(gcb,Realization,general)
[param_struct]=rsimgetrtp(firstorder) %firstorder is name of simulink modell)
In the workspace now there exist the parameters Ks11, Ts11 and ste structure param_struct.
With
save params.mat param_struct
the structure param_struct is saved in the mat file.
rtwbuild(firstorder) %generates Simulink exe file.
Running the exe. file:
[status result]=system('firstorder -p params.mat')
Or
! firstorder -p param.mat
generates the output
To simulate with different parameters an appdesigner app is generated that allow the input of new values for Ks11, Ts11 set the values in param_struct and save param_struct in the params.mat file and call then the Simulink exe file again.
Now my question:
The names Ks11 and Ts11 are not preserved. The location of the parameters in param_struct seems to be lost. The values have to be referenced by
param_struct.parameters.values(1)
,
param_struct.parameters.values(2)
But which parameter is in position 1 or 2 depends from the sequence in which the parameters are created.
If the Simulink model has a large number of tunable parameters it is quite difficult to remember the position in param_struct and maintain and improve the stand alone program

Answers (0)

Categories

Find more on Simulink Coder 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!