Using Simulink    

Discretizing a Model from the Model Discretizer GUI

To discretize a model, follow these steps:

The f14 model, shown below, demonstrates the steps in discretizing a model.

Start the Model Discretizer

To open the tool, select Model Discretizer from the Tools menu in a Simulink model. This displays the Simulink Model Discretizer window.

Alternatively, you can open the Model Discretizer from the MATLAB command window using the slmdldiscui function.

The following command opens the Simulink Model Discretizer window with the f14 model.

To open a new Simulink model or library from the Model Discretizer, select Load model from the File menu.

Specify the Transform Method

The transform method specifies the type of algorithms used in the discretization. For more information on the different transform methods, see Continuous/Discrete Conversions of LTI Models in the Control Systems Toolbox documentation.

The Transform method drop-down list contains the following options:

Specify the Sample Time

Enter the sample time in the Sample time field.

You can specify an offset time by entering a two-element vector for discrete blocks or configurable subsystems. The first element is the sample time and the second element is the offset time. For example, an entry of [1.0 0.1] would specify a 1.0 second sample time with a 0.1 second offset. If no offset is specified, the default is zero.

You can enter workspace variables when discretizing blocks in the s-domain. See Discrete blocks (Enter parameters in s-domain).

Specify the Discretization Method

Specify the discretization method in the Replace current selection with field. The options are

Discrete blocks (Enter parameters in s-domain).   Creates a discrete block whose parameters are retained from the corresponding continuous block. The sample time and the discretization parameters are also on the block's parameter dialog.

The block is implemented as a masked discrete block that uses c2d to transform the continuous parameters to discrete parameters in the mask initialization code.

These blocks have the unique capability of reverting to continuous behavior if the sample time is changed to zero. Entering the sample time as a workspace variable (`Ts', for example) allows for easy changeover from continuous to discrete and back again. See Specify the Sample Time.

The figure below shows a continuous Transfer Function block next to a Transfer Function block that has been discretized in the s-domain. The Block Parameters dialog box for each block is shown below the block.

Discrete blocks (Enter parameters in z-domain).   Creates a discrete block whose parameters are "hard-coded" values placed directly into the block's dialog. The model discretizer uses the c2d function to obtain the discretized parameters, if needed.

For more help on the c2d function, type the following in the Command Window:

The figure below shows a continuous Transfer Function block next to a Transfer Function block that has been discretized in the z-domain. The Block Parameters dialog box for each block is shown below the block.

Configurable subsystem (Enter parameters in s-domain).   Create multiple discretization candidates using s-domain values for the current selection. A configurable subsystem can consist of one or more blocks.

The Location for block in configurable subsystem field becomes active when this option is selected. This option allows you to either create a new configurable subsystem or overwrite an existing one.

Configurable subsystem (Enter parameters in z-domain).   Create multiple discretization candidates in z-domain for the current selection. A configurable subsystem can consist of one or more blocks.

The Location for block in configurable subsystem field becomes active when this option is selected. This option allows you to either create a new configurable subsystem or overwrite an existing one.

Configurable subsystems are stored in a library containing the discretization candidates and the original continuous block. The library will be named <model name>_disc_lib and it will be stored in the current directory. For example a library containing a configurable subsystem created from the f14 model will be named f14_disc_lib.

If multiple libraries are created from the same model, then the filenames will increment accordingly. For example, the second configurable subsystem library created from the f14 model will be named f14_disc_lib2.

You can open a configurable subsystem library by right-clicking on the subsystem in the Simulink model and selecting Link options -> Go to library block from the pop-up menu.

Discretize the Blocks

To discretize blocks that are linked to a library, you must either discretize the blocks in the library itself or disable the library links in the model window.

You can open the library from the Model Discretizer by selecting Load model from the File menu.

You can disable the library links by right-clicking on the block and selecting Link options -> Disable link from the pop-up menu.

There are two methods for discretizing blocks.

Select Blocks and Discretize.   

  1. Select a block or blocks in the Model Discretizer tree view pane.
  1. To choose multiple blocks, press and hold the Ctrl button on the keyboard while selecting the blocks.

  1. Select Discretize current block from the Discretize menu if a single block is selected or select Discretize selected blocks from the Discretize menu if multiple blocks are selected.
  1. You can also discretize the current block by clicking the Discretize button, shown below.

Store the Discretization Settings and Apply Them to Selected Blocks in the Model.   

  1. Enter the discretization settings for the current block.
  2. Click Store Settings.
  1. This adds the current block with its discretization settings to the group of preset blocks.

  1. Repeat steps 1 and 2, as necessary.
  2. Select Discretize preset blocks from the Discretize menu.

Deleting a Discretization Candidate from a Configurable Subsystem

You can delete a discretization candidate from a configurable subsystem by selecting it in the Location for block in configurable subsystem field and clicking the Delete button, shown below.

Undoing a Discretization

To undo a discretization, click the Undo discretization button, shown below.

Alternatively, you can select Undo discretization from the Discretize menu.

This operation undoes discretizations in the current selection and its children. For example, performing the undo operation on a subsystem will remove discretization from all blocks in all levels of the subsystem's hierarchy.


  Model Discretizer Viewing the Discretized Model