1. Introduction
'Matlab' is a powerful general mathematics package with particular strengths in solving problems involving matrices. 'Simulink' is an add in which is a visual 'drag and drop' simulation package for simulating the behaviour of electrical and / or mechanical systems. The 'drag and drop' facility for building block diagrams makes the package very easy to use.
As a simple introduction we will use the software to model a single degree of freedom spring - mass - damper system, see figure 1.
The software is available in Smeaton rooms 105 and 109 plus some other computer labs. Under 'All Programmes', the second alphabetical group beginning with 'M'.
When Matlab has started, the prompt of two arrows pointing to the right is displayed in the right hand window. At this prompt type in: Simulink then press Enter.
A new window opens containing a list of block types.
From the 'File' menu (at top left of this new window) click on 'New' then 'Model'. An empty window appears on the right. You will drag and drop the blocks needed into this model window.

2. Building the Model
It is assumed that a force is being applied to the mass, initially as a step input of 1 N.
2.1 Double click on the 'Sources' group block and a window containing block diagram representations of several sources appears. The 'Step' source can be recognised from its symbol. Move the mouse so the cursor is over this block, press and hold down the left hand mouse button and move the mouse so the cursor and block are in the empty model window at the left hand side.
2.2 This externally applied force will be opposed by the spring force, proportional to the displacement of the mass, and the damper force which is proportional to the velocity of the mass. These opposing forces will need to be included by putting two summing points, each subtracting the appropriate opposing force, thus leaving the net force acting on the mass to go into the next element.
2.3 The summing points are in the 'Math Operations' group, so double click on this group to open it, drag and drop two summing points. Initially these each have two + signs in them. As the 'feedback' forces are negative, the signs in them need to be changed from ++ to +-.This is done by positioning the cursor over each block in turn, clicking the right hand mouse button and selecting Summing Point Properties from the menu. Then change the ++ to +-.

2.4 To connect these together position the cursor over the right hand side of the step generator, press the left mouse button and move the cursor to the left hand side of the summing point then release the button. A link should appear as shown in the diagram, Figure 2.

2.5 The step force, less those from the spring and damper, will accelerate the mass, the net force is divided by the mass to give its acceleration. This is done by a gain block. This is in the Math group.
Right click with the cursor over the block and select the block parameters menu item. In the box enter 1/mass value in kg. We will assume a mass of 1 kg so enter 1.
2.6 The mass acceleration is integrated once to give its velocity and a second time to give its displacement. The integration blocks are found in the 'Continuous' group. Drag and drop two of these into the model window.

2.7 The effect of the displacement has to be fed back and converted to a force by using a gain block with the gain set to the stiffness of the spring (in N/m). Leave as 1 initially.
2.8 The effect of the velocity has to be fed back and converted to a force by using a gain block with the gain set to the damping coefficient of the damper (in Ns/m). Leave as 1 initially.
2.9 Drag and drop two gain blocks to provide these 'feedback' loops. The blocks have to be 'flipped' to point to the left. With the cursor over the gain block, click the right hand mouse button and from the 'Format' heading select 'Flip'.
2.10 Enter the appropriate gain values into the gain blocks - leave as 1 initially.
2.11 To connect up the feedback loops we will have to make a connection to the main line. Do this by putting the cursor over the point on the line where the connection is required to start, press and hold down the 'Ctrl' key and move the cursor to the position that the line is required to run to and release the mouse button and the Ctrl key. The link should appear.

2.12 To see how the displacement fluctuates, an oscilloscope will be used. Oscilloscopes are in the 'Sinks' group. Run a connecting link from the displacement line to the scope input.
The model should now appear similar to the schematic shown in Figure 2.

3.1 Run the simulation by clicking on 'Simulation', 'Start'. Double click on the scope to show its screen, then click on the binocular icon at the top of the scope screen to auto-scale the scope display.
3.2 To get a better display it may be necessary to set a specific maximum time step. From the 'Simulation' menu, click on Simulation Parameters' and change the maximum time step from 'auto' by entering 0.01 seconds.

3.3 Investigate the effects of changing the spring stiffness and the damping coefficient.

3.4 To investigate the effects of a sinusoidal input, click over the Step icon in the circuit and press delete. from the 'Sources' group drag in a 'Sine' source and connect it up.

3.5 To investigate the effects of a non-standard input the 'Signal Builder' source must be used. Having dragged and dropped this source into the model window it will need to be opened and modified to give the required signal. To do this place the cursor over the 'Signal Builder Block' click the right hand mouse button then click on 'Open', from the top of the menu list. The default signal is a pulse input, this can be edited to a more complex signal by: