Main Content

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

  1. Change to a working folder by using the cd command.

  2. Open sldrtex_model.

  3. Open the Transfer Fcn block parameters dialog box.

  4. Replace the existing value of Denominator coefficients ([1 70 10000]) with Dmp.

    Apply these settings for the transfer function in the block parameters dialog box.

  5. Click the Property Actions button after Dmp and select Dmp: Create.

  6. In the Value field, select Simulink.Parameter.

  7. In the Location field, select Base Workspace.

  8. Click Create.

    If the model is already in Run in Kernel mode, the data type defaults to Simulink.Parameter in the base workspace.

  9. In the Simulink.Parameter: Dmp dialog box, in the Value field, enter [1 70 10000].

    For the rest of the fields, take the defaults.

    Apply these setting for Dmp in the Simulink Parameter dialog box.

  10. In the Simulink.Parameter: DMP dialog box, click Apply and then click OK.

  11. In the Block Parameters: Transfer Fcn dialog box, click OK.

Tune Parameter Object

This procedure continues from the steps in Create Parameter Object.

  1. In the Simulink Editor, on the Desktop Real-Time tab, select Run in Real Time > Stop Time and change the Stop Time to Inf.

  2. Open the Scope block.

  3. Open the Transfer Fcn block parameters dialog box.

  4. 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.

  5. To start execution, on the Desktop Real-Time tab, click Run in Real Time.

    The scope window displays the signal from simulation.

  6. In the Simulink.Parameter: Dmp dialog box, change Value to [1 30 10000] and click Apply.

  7. Change the active dialog box by clicking on the model in the Simulink Editor, and then press Ctrl-D.

    The scope window displays the ripple signal from simulation.

  8. Change Value to [1 180 10000] and click Apply.

  9. Change the active dialog box by clicking on the model in the Simulink Editor, and then press Ctrl-D.

    The scope window displays the ripple minimum signal from simulation.

  10. On the Desktop Real-Time tab, click Stop.

Related Topics