Tune Block Parameters with Data Navigation
You can create tunable global parameters by embedding MATLAB® variables in block dialog boxes with data navigation. You can tune the parameters by changing the variable values during execution. In Connected IO mode or accelerator mode, Simulink® transfers the new values to the model that is being simulated. In Run in Kernel mode, Simulink transfers the new values to the real-time application that is running in the kernel mode process.
You can permanently store parameter objects and other external data in a data dictionary.
For this example, your goal is to minimize ringing in the transfer function.
This procedure begins with the square-wave transfer function model
sldrtex_model
. To open this model, in the MATLAB Command Window, type:
openExample('sldrtex_model')
This model opens in Connected IO mode.
Create Parameter Object
Change to a working folder by using the
cd
command.Open
sldrtex_model
.Open the Transfer Fcn block parameters dialog box.
Replace the existing value of Denominator coefficients
([1 70 10000])
withDmp
.Click the Property Actions button after
Dmp
and select Dmp: Create.In the Value field, select
Simulink.Parameter
.In the Location field, select Base Workspace.
Click Create.
If the model is already in Run in Kernel mode, the data type defaults to
Simulink.Parameter
in the base workspace.In the Simulink.Parameter: Dmp dialog box, in the Value field, enter
[1 70 10000]
.For the rest of the fields, take the defaults.
In the Simulink.Parameter: DMP dialog box, click Apply and then click OK.
In the Block Parameters: Transfer Fcn dialog box, click OK.
Tune Parameter Object
This procedure continues from the steps in Create Parameter Object.
In the Simulink Editor, on the Desktop Real-Time tab, select Run in Real Time > Stop Time and change the Stop Time to
Inf
.Open the Scope block.
Open the Transfer Fcn block parameters dialog box.
Click the Property Actions button after
Dmp
and select Dmp (base workspace) > Open.Before you start execution, open this dialog box. You cannot open variable
Dmp
while the real-time application is running.To start execution, on the Desktop Real-Time tab, click Run in Real Time.
In the Simulink.Parameter: Dmp dialog box, change Value to
[1 30 10000]
and click Apply.Change the active dialog box by clicking on the model in the Simulink Editor, and then press Ctrl-D.
Change Value to
[1 180 10000]
and click Apply.Change the active dialog box by clicking on the model in the Simulink Editor, and then press Ctrl-D.
On the Desktop Real-Time tab, click Stop.