Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

Creating a Simple Model

Overview

This section describes how to model a simple dynamic system using Simulink software. After you create the model, you can simulate it as described in Simulating the Model.

Creating a New Model

Before you can begin building your model, you must start Simulink and create an empty model.

To create a new model:

  1. If Simulink is not running, enter simulink in the MATLAB Command Window to open the Simulink Library Browser.

  2. Select File > New > Model in the Simulink Library Browser to create a new model.

    The software opens an empty model window.

Adding Blocks to Your Model

To construct a model, you first copy blocks from the Simulink Library Browser to the model window. To create the simple model in this chapter, you need four blocks:

To add blocks to your model:

  1. Select the Sources library in the Simulink Library Browser.

    The Simulink Library Browser displays the Sources library.

  2. Select the Sine Wave block in the Simulink Library Browser, then drag it to the model window.

    A copy of the Sine Wave block appears in the model window.

  3. Select the Sinks library in the Simulink Library Browser.

  4. Select the Scope block from the Sinks library, then drag it to the model window.

    A Scope block appears in the model window.

  5. Select the Continuous library in the Simulink Library Browser.

  6. Select the Integrator block from the Continuous library, then drag it to the model window.

    An Integrator block appears in the model window.

  7. Select the Signal Routing library in the Simulink Library Browser.

  8. Select the Mux block from the Sinks library, then drag it to the model window.

    A Mux block appears in the model window.

Moving Blocks in the Model Window

Before you connect the blocks in your model, you should arrange them logically to make the signal connections as straightforward as possible.

To move a block in the model window, you can either:

Arrange the blocks in the model to look like the following figure.

Connecting Blocks in the Model Window

After you add blocks to the model window, you must connect them to represent the signal connections within the model.

Notice that each block has angle brackets on one or both sides. These angle brackets represent input and output ports:

The following sections describe how to connect blocks by drawing lines from output ports to input ports:

Drawing Lines Between Blocks

You connect the blocks in your model by drawing lines between output ports and input ports.

To draw a line between two blocks:

  1. Position the mouse pointer over the output port on the right side of the Sine Wave block.

    Note that the pointer changes to a cross hairs (+) shape while over the port.

  2. Drag a line from the output port to the top input port of the Mux block.

    Note that the line is dashed while you hold the mouse button down, and that the pointer changes to a double-lined cross hairs as it approaches the input port of the Mux block.

  3. Release the mouse button over the output port.

    The software connects the blocks with an arrow that indicates the direction of signal flow.

  4. Drag a line from the output port of the Integrator block to the bottom input port on the Mux block.

    The software connects the blocks.

  5. Select the Mux block, then Ctrl+click the Scope block.

    The software automatically draws the connection line between the blocks.

      Note   The Ctrl+click shortcut is especially useful when you are connecting widely separated blocks, or when working with complex models.

The model should now look similar to the following figure.

Drawing a Branch Line

The model is almost complete, but one connection is missing. To finish the model, you must connect the Sine Wave block to the Integrator block.

This final connection is somewhat different from the other three, which all connect output ports to input ports. Because the output port of the Sine Wave block already has a connection, you must connect this existing line to the input port of the Integrator block. The new line, called a branch line, carries the same signal that passes from the Sine Wave block to the Mux block.

To weld a connection to an existing line:

  1. Position the mouse pointer on the line between the Sine Wave and the Mux block.

  2. Press and hold the Ctrl key, then drag a line to the Integrator block's input port.

    The software draws a line between the starting point and the input port of the Integrator block.

The model is now complete. It should look similar to the following figure.

Saving the Model

After you complete the model, you should save it for future use.

To save the model:

  1. Select File > Save in the model window.

  2. Specify the location in which you want to save the model.

  3. Enter simple_model in the File name field.

  4. Click Save.

    The software saves the model with the file name simple_model.mdl.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS