You are on page 1of 15

Lab Experiment 2

Understand the process of solving Differential Equations with Simulink and


MANIPULATE for differential equations of different orders.

Objective:
The Objective of this lab is to understand the process of solving differential equations of
different orders on Simulink.

Solving differential equations in Simulink 


In Simulink library browser, there is a block named as Integral as shown in the figure below,

Figure 1: Integrator
As the name suggests, this block is used to calculate the integral of the signal provided at the
input i.e. left side of the block. In case of solving a differential equation, the major task to do is
to integrate the given equation which will return the function without the derivative.
Integration of the derivative of a function is equal to the function itself. The purpose of the
integral block here is the same. Number of integral blocks used in a block diagram is equal to the
order of the differential equation we are going to solve hereby in the problem. For instance, if we
want to solve a 1st order differential equation, we will be needing 1 integral block and if the
equation is a 2nd order differential equation the number of blocks used is two.

Block diagram of differential equations in Simulink


Open the Simulink by either typing Simulink in the command window or using
the Simulink icon. On the Simulink start page click on the library browser icon to open the
library browser,

Figure 2: Library browser


In the Simulink library browser, a large number of blocks are present. Click on the most
commonly used sub block,

Figure 3: Commonly used blocks


To solve the differential equation, the first step to be done here is to rearrange the differential
equation. On the left-hand side, write the highest order derivative and move all the remaining
terms on the right-hand side as given in the equation,

From the library browser, select the commonly used blocks and then select integral block,
Figure 4: Integral block
Drag and drop the integral block on the Simulink blank project created previously. Also save the
project. If we are working with a second order differential equation, we will place two integral
blocks,

Figure 5: Second order integral


And if we are working with third order differential equation, we will be using three integral
blocks,

Figure 6: 3rd order integral


In this case, however, the number of blocks to be used is 2 as the order of differential equation is
2. To provide the coefficient present with each equation, we will use a gain block.

Figure 7: Gain block


We will need two gain blocks; the second will be used to multiple 5. Also, to place the 1 present
at the right-hand side of the given equation, we will need a constant block,
Figure 8: Constant block
And to add all the terms on the right-hand side of the rearranges equation we will use a
summation block,
Figure 9: Sum block
Place all the components as shown in the figure below, before jumping to the connecting portion,

Figure 10: Placed components


As we want to first multiply the term and then add it hence, we should flip the gain block. This
can be done by right clicking on the block then select Rotate & Flip and then select Flip block,

Figure 11: Flipping block


Double click on the gain block and change the gain of the block,

Figure 12: Changing gain


Do the same with the other gain block and change its gain to 5,
Figure 13: Gain blocks
Next comes the summation block. Double click on the summation block. We can also change the
shape of the summation block from round to rectangle in the block parameters dialog box of
sum,

Figure 14: Shape of sum block


We can also change the number of terms to be added here by changing the sequence of list of
signs in the parameters of the block, and also change them from sum to subtract,
Figure 15: List of signs
This list is adjusted according to the right-hand side of the rearranged equation. After this
connect the constant to the + side of the sum block,

Figure 16: Constant


Connect all the integration blocks together and label them accordingly to perform all the
derivative iterations,

Figure 17: Derivation steps


Now, Connect the wire with the gain block 4 and connect the output of the gain block to the
negative sign of the sum block,
Figure 18: Second term
Now, to evaluate the third term, connect the wire labeled as y to the input of the gain block with
gain 5 and connect its output to the only left slot in sum block as shown in the figure below,

Figure 19: Third term


From the library browser select an oscilloscope from the commonly used blocks, named
as Scope,
Figure 20: Scope
Connect it at the output i.e. at the end of the wire labeled as y. The complete block diagram to
perform the solution of the differential equation is shown in the figure below,
Figure 21: Complete block diagram
Run the block diagram from the Run icon as shown in the figure below,

Figure 22: Running the block diagram


After the simulation is complete double click on the scope and the waveform of the equation is
displayed,

Figure 23: Output


Post Lab Assignment

Perform the above discussed problem on differential equations of different orders. Use the
equations given below and solve them on Simulink.
d2 y dy
 +6 −3=0
dx 2
dx
2
d y dy
=3−6
dx 2
dx
3 2
d y d y dy
 3
+2 2 +3 −5=0
dx dx dx
3 2
d y d y dy
3
=5−2 2 −3
dx dx dx

d4 y d2 y dy
 + 2 −3 + y=9
dx 4
dx dx
d4 y d2 y dy
=9− 2 +3 − y
dx 4
dx dx

Comments:

_______________________________________________________________________________

_______________________________________________________________________________

_______________________________________________________________________________

You might also like