Constructing a Simulink model

To compute trajectories with MATLAB by means of block diagrams, the tool Simulink should be used. To open Simulink, type 'simulink' in your command window or press the icon \includegraphics[height=8mm]{ch7_simicon} in your MATLAB window. Now, the Simulink Library Browser should appear. A new file can be opened by selecting File$ >$ New$ >$ Model or selecting the icon on the toolbar. In the window appearing, one should build the model. Basically, you will have to draw the block diagram. Hereto, blocks from the Library Browser should be dragged towards the model while holding your left mouse button.

\begin{figure}\centering
\epsfig{file=ch7_sim_lb1.eps,width=800px}
\end{figure}

\begin{figure}\centering
\epsfig{file=ch7_sim_model1.eps,width=800px}
\end{figure}

In the library browser, you will find the integrator block in the category "Continuous", the gain and sum block are part of the category "Math Operations". When a block is inserted in the model, one can flip the block (press the right mouse button on block, select Format$ >$ Flip). To connect two blocks, click on the $ >>$ exiting the first block, hold your right-mouse-button and drag a line towards the $ >>$ entering the second block. You can give a name to a signal by double-clicking on the connection.

Sometimes, you will need to split a signal, for example the signal dx in the example of the previous section. Hereto, first make one of the connections, click on the $ >>$ entering the third block you want to connect, hold your left-mouse-button and drag a line towards the already existing connection.

Blocks and arrows can be moved in your model by using either the arrows on your keyboard or by dragging them with your mouse.

Many blocks in Simulink have certain parameters. To edit these parameters, double click on the block and change the value. The particular gain used is a parameter of the gain block. The initial value of a signal exiting an integrator block is a parameter of this block. In the parameters of the add-block, one can make the block subtract signals instead of add them, by changing the "list of signs" from "$ \vert++$ " to "$ \vert+-$ ".

The integrator block has its initial condition as parameter. Here, one specifies the initial output of the integrator block. By changing these initial conditions, a Simulink model can be used to compute trajectories from predefined initial conditions.

Inputs in Simulink have to be defined as a function of time, for example $ u(t)=3\sin(2t)$ . You will find many possible inputs in the Sources-category of your Library browser. Most used are the sine wave, step or constant blocks. A sine wave block has the properties amplitude, frequency and phase, the latter describing the initial phase of the signal. A step block has parameters initial time, initial value and final value. A constant source has the constant value as a parameter.

To handle outputs in Simulink, one needs to use the blocks in the category Sinks in the Library browser. Most used are the "Scope", "To File", and "To Workspace blocks". A scope will visualize the signals entering it. When you have finished a simulation, double-click on the scope to see the results. The "To File" block saves the entering signal to a .mat file. When you select the block properties, you can change the file name, and the name of the stored variable. The block "To Workspace" saves the signals to the workspace, such that one can use them later in the command window. In this block's properties, one can change the variable name, and choose whether the data should be saved as structure, structure with time or array.

It is allowed to call variables that are present in your workspace in block parameters. For example, a gain-block with gain "k" will work properly, when a scalar "k" is available in the MATLAB workspace.

To save your model, press the "save" button in the toolbar of your model window. Simulink models will be saved with the extension .mdl. Later, you can open these models by selecting the file saved.

Please note, that the Library browser contains many more blocks as mentioned in this section. When you double click on a certain block in the library browser, you will see the purpose and parameters of the block.


Previous      Next      Up      Contents


Esteur 2010-03-22