Introduction to Simulink - Getting Started


Related Documents Contents

Introduction

In this first step, you start MATLAB and then start Simulink. A short discussion of the significance of blocks is presented. The notion of having a block selected is presented. You will move, copy, and delete model blocks, lastly you will learn how to save and name your design by using the save-as command.

Starting Up Simulink

Before starting Simulink, you must start MATLAB. For the following, it is assumed that you are running Windows 95. This document was written on a machine that has MATLAB 5.1 installed, if your machine has a newer version make the substitution when you select the following with your mouse.

Start => Programs => MATLAB 5.1 => MATLAB

With MATLAB running there are three ways to start Simulink.

After MATLAB finishes processing the command, your desktop will include the MATLAB command window, a new empty model window, and the Simulink block library window, shown below.


Simulink block library

In Simulink, blocks are used to build up a model. Unlike the blocks in a diagram that we draw by hand, the blocks in Simulink are active and allow the program to simulate the behavior of the entire system. In the Simulink library window the icons each refer to a different block library, each of which contains a class of blocks. For now we will only consider the libraries used to build the first model, the libraries are listed below.

Source type blocks produce input signals.
The Sine Wave block is a source type block.

Sink type blocks provide a place for output.
The scope block is a sink type block.

Linear type blocks perform a linear transformation.
The Integrator is a linear type block.

Connection type blocks are involved with forming
vector signals, the Mux block is an example.

The descriptive titles Sources and Sinks deserve a special comment as they do not refer to power supplies. Remember that while power supplies are important in real circuits, in drawing a block diagram we are concerned only with signals that convey information in some way. Block diagrams are necessarily abstract in form, this abstraction greatly simplifies the analysis.

In developing a block diagram, we use source type blocks to produce the input signals. Conversely, sink type blocks provide a place for a model to have output appear. Linear type blocks perform a linear transformation on signals. Lastly, the connections type blocks are used for switching and forming vector signals.

Adding a block from a library

To open a block library, double click on the associated library icon in the Simulink block library window. After opening the Sources library, the Sources library window opens, as shown below. Go ahead and double click on the icon if you have not already done so.


Sources library window

To add the first block to the diagram, point the mouse at the Sine Wave block in the Sources library window and press the left mouse button. Without releasing the left mouse button, drag the mouse to the new model window and release the mouse button.


Diagram window with Sine Wave block

Selecting, Copying, and Moving a Block

An important point needs to be made, to direct an action on a block or other object, the object must first be selected. The simplest way to select an object is to point at it with the mouse and click the left mouse button. Selected blocks have small black handles that appear in the corners, as the figure above shows. To un-select and object, either select something else or point the mouse at nearby empty space and click the left mouse button.

Note that when you point the mouse at the Sine Wave block, then press and hold down the left mouse button, an outline of the selected object moves with the mouse. If you drag the mouse to another location in the same window, when you release the left mouse button, the selected object is simply moved to that new location.

If however, you press the left mouse button on a block and drag the mouse to a different window, a copy of the selected object will appear in the new window. This is how you copied the Sine Wave block to the diagram window. Go back and copy a second Sine Wave block from the Sources library window to the diagram window.

Note that you will not be able to copy a second Sine Wave block back to the Sources library window, or move its blocks, as library windows are write protected.

Each block name in a diagram must be unique and must contain at least one character. Because names must be unique, in producing a second copy of a block, the inherited block name includes an instantiation number that is used to tell the blocks apart. The second Sine Wave block is named Sine Wave 1, and the third Sine Wave block is named Sine Wave 2, and so on.

Press the control key, point the mouse at a Sine Wave block. Next press and hold down the left mouse button to drag the mouse to a nearby location in the same window, then release the left mouse button. Note that with the control key pressed, the block was not moved but was copied. The diagram window should look similar to the figure below, note that the block named Sine Wave 2 is selected.


Three copies of the Sine Wave block

Forming a Group of Selected Blocks

So far you have found that by simply pointing at a block and clicking the left mouse button will simultaneously select that block and will unselect another block. At times however, it is useful to have several blocks selected. To form a group of selected blocks you have two options.

At this point go ahead and select a group of blocks. Practice unselecting and try each method of selecting blocks. Note that when a group of blocks is selected, when you perform a move, all the selected blocks move together. You will find later that besides selecting blocks, you can select the lines used to interconnect blocks.

Deleting a Block

Another useful command is delete. To delete a block, select it and then press the backspace or the delete key. If a group of blocks is selected, the delete command will delete all the selected blocks. Make sure to get some practice selecting blocks, copying, and deleting. When you are ready to move on, leave one copy of the Sine Wave block in the diagram window and delete the rest.

Undoing and Redoing

Now that you know how to delete objects, to get yourself out of trouble, you will want to know about the Undo command. The Simulink documentation indicates that you can cancel the effects of up to 101 consecutive operations by choosing Undo from the Edit menu. The following is a list of some of the operations that may be undone.

Like most modern software, Simulink goes one step further by also allowing you to reverse the effects of Undo. Simply select Redo from the Edit menu. To summarize Undo and Redo;

To undo, in the model window either press control-Z, or with your mouse select Edit=>Undo

To redo, in the model window either press control-Y, or with your mouse select Edit=>Redo

Save As Command

So far the design consists of only one block, but now is a good time to use the save as command to assign a name to your model and select a directory to work from. If you are using a PC on campus, it is strongly suggested that you use the M: drive, which corresponds to the home directory in your Unix account. By selecting the M: drive, your files will be accessible from any PC in the department. If you are using a PC that is not networked, use the C: drive instead. Lastly, rather than just saving your files in your home directory, save the files in directory with a name like simulink. Use the mouse to select the following in the design window.

File => Save As

In the pop-up window, near the Save-in field, click on the pull-down button and scroll through the list that pops up; When you find the M: drive, click on it. Next, to create a folder named simulink, click on the Create New Folder Button . A new folder named "new folder" appears in the file display pane. Click on the folder name, change it to simulink, then press the Enter key. To open the simulink folder, double click on the icon. In the pop-up window, enter first.mdl in the File-name field and then with the mouse, click Save. Your model design window should now be titled "first" indicating that the design has been properly named.

Shutting Down

To shut down Simulink and MATLAB at the same time, make the following selection with the mouse. If you make changes to your design and not save them, when you exit MATLAB may ask if you want the changes saved.
File => Exit MATLAB

This document was written by Jonathan M Hill (jmhill@ece.wpi.edu), using HTML Standard 3.2.
Revised: Sun Mar 11 20:57:45 EST 2001