Documentation

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 normal or accelerator mode, Simulink® transfers the new values to the model that is being simulated. In external 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 (matlab: open_system(docpath(fullfile(docroot, 'toolbox', 'sldrt', 'examples', 'sldrtex_model')))). This model opens in normal mode.

First, install the Simulink Desktop Real-Time™ kernel and cd to a working folder.

Create Parameter Object

  1. Open sldrtex_model.

  2. Open the Transfer Fcn block parameters dialog box.

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

  4. Click Apply.

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

  10. Click OK.

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

Tune Parameter Object

  1. Set Simulation > Mode to External.

  2. In Simulink Editor, change Simulation stop time to Inf.

  3. Open the Scope block.

  4. Open the Transfer Fcn block parameters dialog box.

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

  6. To start execution, on the Simulink Editor toolbar, click the Run button .

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

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

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

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

  11. Click Stop.

Related Topics

Was this topic helpful?