>> cd M:\simulink
This time start Simulink by entering at the MATLAB prompt the name of the model that you saved.
>> firstTo continue the tutorial, besides having the model window open, you will need to access the block libraries. In the MATLAB window type in the command simulink.
>> simulink
Note that when you issued the command simulink, the block library opened, but this time a blank model window did not open. In general when you give the simulink command, a blank model window will open only if a model window is not already open.
Arrange the blocks listed into the pattern shown below. For a refresher on how to copy blocks from a library, go to the "Add from Library," section. For a refresher on how to copy and move blocks, go back to the "Selecting, Copying, and Moving a Block" section of the tutorial.
After you have copied a block from a library, you will want
to close it, to reduce window clutter.
Note that to close each library window, click the window close
button
which is located in the upper
right hand corner of the window.
| ![]() |
In general the inputs to a block are on the left, a > symbol points into the block. In addition, outputs are generally on the right, a > symbol points out of the block. Consider the mux block shown below.
Note that the mux block has three inputs, but we only need two. To change the number of inputs double click on the mux block, and in the Parameters field, change the number of inputs from 3 to 2, then click the CLOSE button. In general the parameters associated with any block can be altered this way.
Now it's time to connect the blocks in the model window. You will start by connecting the output of the Sine Wave block to the topmost input port of the Mux block. To start, use the mouse to position the pointer over the output port of the Sine Wave block. Notice that as illustrated below, the pointer changes to cross hairs, this is how Simulink indicates that it can start a connection.
Without moving the mouse, press and hold down the left mouse button. Use the mouse to move the cross hairs to the topmost input port of the Mux block. In moving the mouse with the left button pressed, two things happen. First, a dashed line is drawn, this will be the connection line. Second, when the cross hairs arrive at the input port to the Mux bloc, the cross hairs change in appearance to double cross hairs, this is how Simulink indicates that its ready to complete the connection. With the mouse positioned, release the left mouse button. The completed connection should look like what's shown below.
If you release the left mouse button before the pointer changes to double cross hairs, the connection will be left dangling. To deal with this situation, you can either use the mouse to select Edit=>Undo_Add_line and try again, or you may add to the line to complete the connection.
Follow the same steps to add a connection between the output port of the Mux block, to the input port of the Scope block. The completed connection should look like what's shown below.
Without moving the mouse, press and hold down the Ctrl key and then press and hold the left mouse button. Drag the pointer to the input port of the Integrator block and release the mouse button. Simulink draws a line from the starting point to the input port of the Integrator block.
To finish the connections, add a line from the output of the Integrator block, to the input port of the Mux block. When you're done the model should look similar to the following. To move a line, select it and move the handle blocks.
A word is needed regarding the connection from the Mux block to the Scope block; That line is referred to as bearing a vector signal. A vector signal is a concatenation of signal lines. The idea of forming a vector signal with a Mux block is analogous to taking handful of wires and wrapping tape around the bundle. Most Simulink block input ports will accept a scalar or vector signal. Likewise, a block output port my produce either a scalar or vector signal. To make it more obvious which lines carry vector signals, select with the mouse;
Format => Wide Vector LinesThe mux block is used here to produce a vector signal so that the Scope block will display two signals. To return the display of vectors back to normal, repeat the previous selection with the mouse.
Annotations provide textual information about a model. You can add an annotation to any unoccupied area of your block diagram. To create a model annotation, double click in an unoccupied area. A small rectangle appears and the pointer changes to a vertical insertion bar. Start typing the annotation content. To start a new line, simply press the Enter key. Each line is centered within the rectangular box that surrounds the annotation. To close the annotation, click with the mouse elsewhere in the window.
In your block diagram you will place a title at the top and you will place your name and date at the lower right, as illustrated below. In performing homework assignments it is important that a title, your name, and date be included. Block diagrams missing this information are incomplete and will lose credit.
To move an annotation, drag it to a new location. To change the font size of an annotation, select it and with the mouse select Format=>Font. In the pop-up window select the desired font size and then click OK. The font size will change when the annotation is deselected, to do so simply click elsewhere.
In the above illustration the name and date are in a 10 point regular font, the title is in a 16 point bold font. After you enter the title, you will want to change the font back to a comfortable size. For general purposes the 10 point regular font is reasonable.
Labels can be added to lines to further annotate your model. To create a signal label, double click on a line segment and type the label at the insertion point. When you click on another part of the model, the label fixes its location. Take care to double-click on the line. If you double click in an unoccupied part of the model, you will create a model annotation instead. The figure below shows the model with the signal labels IN and OUT added.
To move a signal label, point at it with the mouse, press and hold down the left mouse button and drag the label to a new location. To unselect a label, click elsewhere in the model. Note that Simulink is fairly restrictive in where it will allow you to place a label. In general, a label must be immediately adjacent to a line. OK, you have done great so far. Before you do anything else, make sure to save your work.
On the Windows-95 desktop double click the My Computer icon and in the pop-up window double click the Control Panel icon. Next, in the Control Panel pop-up window, double click on the Printers icon. In the Printers pop-up window you will select a printer. If you are in AK227 then double click on the AK227 printer icon. If however you are in the first floor PC lab then double click on the AK120 printer icon. In the printer pop-up window select Printer => Set_as_default. Then, clean up the mess and close all those windows.
With the default printer selected, printing a block diagram out could not be simpler. From the Matlab window, enter the following command;
>> print -sfirst
The "-s" is referred to as a flag that instruct Matlab to retrieve the block diagram of a system to print. Of course, first is the name of the block diagram. Naturally, you will want to be in the same directory that the block diagram named first is in, before you issue the print command. As described earlier, to change directories, use the cd command.