Lab 2-CS-Lab
Lab 2-CS-Lab
Lab 2-CS-Lab
Figure 2.1 (a): Mass-Spring system Figure 2.1 (b): Block Diagram
Begin the solution by drawing the free-body diagram as shown in Figure 2.2. We assume
that the mass is traveling toward the right. Thus, only the applied force points towards right; all
other forces impede the motion and act to oppose it. Hence, the spring, viscous damper
(friction), and the force due to acceleration point towards left. The spring force is assumed to
d2 x(t) dx(t)
𝑀 +𝐵 = 𝐹(𝑡) (2.4)
dt 2 dt
dv(t)
𝑀 + 𝐵𝑣 = 𝐹(𝑡) (2.5)
dt
dv(t) 𝐹(𝑡) 𝐵𝑣
or = − (2.6)
dt 𝑀 𝑀
Eq. (2.6) is a first order linear ODE. Using MATLAB solver ode45, we can solve this
equation using following steps.
Figure 2.3
Implementation using MATLAB/Simulink:
Draw the Simulink model diagram as shown in Figure 2.4.
Figure 2.4
Simulate the model of Figure 2.4 and observe the output as shown in Figure 2.5.
Figure 2.5
𝑑 2 𝑥(𝑡) 𝑑𝑥(𝑡)
𝑀 + 𝐵 + 𝐾𝑥(𝑡) = 𝐹(𝑡) (2.7)
𝑑𝑡 2 𝑑𝑡
The second order differential equation will be decomposed into a set of two 1st order
differential equations as follows:
𝑥(𝑡) 𝑋1 𝑑𝑋1
= 𝑋2
(Displacement) 𝑑𝑡
𝑑𝑥(𝑡)
𝑋2 𝑑𝑋2 𝐵 𝐾 𝐹(𝑡)
𝑑𝑡 = − 𝑋2 (𝑡) − 𝑋1 (𝑡) +
(Velocity) 𝑑𝑡 𝑀 𝑀 𝑀
𝑑𝑋1
𝑋 𝑋̇ 𝑑𝑡
In vector form, Let 𝑋 = [ 1 ]; [ 1 ] = [𝑑𝑋 ]; then the system can be written as:
𝑋2 𝑋2 ̇ 2
𝑑𝑡
𝑋̇ 𝑋2
[ 1] = [ 𝐵 𝐾 𝐹(𝑡)]
𝑋2̇ − 𝑋2 − 𝑋1 +
𝑀 𝑀 𝑀
Figure 2.6
Implementation using MATLAB/Simulink:
Draw the Simulink model diagram as shown in Figure 2.7.
Figure 2.7
Simulate the model of Figure 2.7 and observe the output as shown in Figure 2.8.
Exercise Problems
Question No. 1:
Find the solution of first order differential equation of RC circuit given in Figure 2.9 using
Figure 2.9
Question No. 2:
a. Find the solution of second order differential equation of RLC circuit given in Figure 2.10
Figure 2.10