0% found this document useful (0 votes)
37 views11 pages

THT - CLASS01 - 13621062 - Evelio Christian Fresley

1) The state space model of the system is defined by the matrices A, B, C, and D. 2) The transfer function of the system is derived using Laplace transformation as G(s) = (s^2 + 11s + 9)^-1. 3) The time response is obtained using inverse Laplace transformation and contains terms involving exponential, hyperbolic cosine and sine functions. 4) MATLAB is used to numerically solve and plot the time response, showing it is a stable oscillatory solution. Decreasing or increasing damping C affects the amplitude and frequency of oscillations.

Uploaded by

ac3.evfrez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views11 pages

THT - CLASS01 - 13621062 - Evelio Christian Fresley

1) The state space model of the system is defined by the matrices A, B, C, and D. 2) The transfer function of the system is derived using Laplace transformation as G(s) = (s^2 + 11s + 9)^-1. 3) The time response is obtained using inverse Laplace transformation and contains terms involving exponential, hyperbolic cosine and sine functions. 4) MATLAB is used to numerically solve and plot the time response, showing it is a stable oscillatory solution. Decreasing or increasing damping C affects the amplitude and frequency of oscillations.

Uploaded by

ac3.evfrez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

TAKE HOME TEST

SISTEM DINAMIKA
AE 2203

Oleh:

Evelio Christian Fresley / 13621062

AEROSPACE ENGINEERING
FACULTY OF MECHANICAL AND AEROSPACE
ENGINEERING
INSTITUT TEKNOLOGI BANDUNG
2023
Problem:
Concerning a following system of 2nd order Ordinary Differential Equation.
𝑀𝑥̈ + 𝐶𝑥̇ + 𝐾𝑥 = 𝐹0 𝑠𝑖𝑛(𝜔𝑡)
With,
𝐾
𝑀 = 1 + 𝑄 = 1; 𝐶 = 3 + 𝐴 + 𝑅 = 11; 𝐾 = 6 + 𝐵 + 𝑆 = 9; 𝜔 = 0.5√ = 1.5
𝑀
Subtituting the coefficients → 𝑥̈ + 11𝑥̇ + 9𝑥 = 𝐹0 𝑠𝑖𝑛(1.5𝑡)
With 𝐹0 = 1; The initial conditions are 𝑥(0) = 0; 𝑥̇ (0) = 0.
1) Determine the state space model of the system.

A state-space model is a mathematical representation of a physical system that consists of a


set of input, output, and state variable(s) that corelated by using first-order differential equations.
That said equation are,
𝑥̇ = 𝐴𝑥 + 𝐵𝑢  Dynamic Eq.
𝑦 = 𝐶𝑥 + 𝐷𝑢  Output Relation

With, A as the dynamic system matrix, B and C are the input and output matrix, D is the feed-
forward matrix, and x (state variables), y, and also u (input variables) that dependent as a function of
time. To find the state space, firstly isolate 𝑀𝑥̈ in the LHS with the rest of the bunch in the RHS;
𝑥̈ = −11𝑥̇ − 9𝑥 + 𝑠𝑖𝑛(1.5𝑡)
By defining 𝑥 = 𝑥1 , 𝑎𝑛𝑑 𝑥̇ = 𝑥2 , The relation of its derivative can be obtained which is,
𝑥1 𝑥 𝑥̇
𝑥 = ( ) = ( ) , 𝑥̇ = ( )
𝑥2 𝑥̇ 𝑥̈
by substitute the equation above to the Dynamic equation and match equation of 𝑥̈ :
𝑥̇ 0 1 𝑥 0
( )=[ ] ( ) + [ ] 𝑠𝑖𝑛(1.5𝑡)
𝑥̈ −9 −11 𝑥̇ 1
Thus, we can conclude that:
0 1 0
𝐴 =[ ] , 𝐵 = [ ] , 𝑎𝑛𝑑 𝑢 = 𝑠𝑖𝑛(1.5𝑡)
−9 −11 1
2) The transfer function of the system by means of Laplace transformation.

To find the transfer function of the system, we must Laplace transform both side of the
dynamic equation according to the Laplace transformation table. Then equation become:
1.5
𝑠 2 𝑋(𝑠) − 𝑠 ∙ 𝑥(0) − 𝑥̇ (0) = −11(𝑠 ∙ 𝑋(𝑠) − 𝑥(0)) − 9 ∙ 𝑋(𝑠) + 𝑠2 +1.52
1.5
𝑠 2 𝑋(𝑠) = −11(𝑠 ∙ 𝑋(𝑠)) − 9 ∙ 𝑋(𝑠) + 2
𝑠 + 1.52
1.5
(𝑠 2 + 11𝑠 + 9) ∙ 𝑋(𝑠) = 2
𝑠 + 1.52
1.5
2 2
𝑋(𝑠) = 2𝑠 + 1.5
𝑠 + 11𝑠 + 9
𝑦(𝑠)
The equation of transfer function, 𝐺(𝑠) = 𝑈(𝑠)
1.5
𝑠 + 1.52
2
2 1
𝐺(𝑠) = 𝑠 + 11𝑠 + 9 = 2
1.5 𝑠 + 11𝑠 + 9
𝑠 2 + 1.52
3) The time response function of the system by means of inverse Laplace transformation.
To be able to inverse Laplace transformation the transfer function, we must equate 𝐺(𝑠) to
𝑦(𝑠) by using:
𝑦(𝑠) = 𝐺(𝑠) ∙ 𝑈(𝑠)
1 4 ∙ 1.5
𝑦(𝑠) = 2 ∙
𝑠 + 11𝑠 + 9 4(𝑠 2 + 1.52 )
1 6
𝑦(𝑠) = 2 ∙ 2
𝑠 + 11𝑠 + 9 4𝑠 + 9
Using partial fraction decomposition to be able to perform inverse Laplace transformation,
88 172√85 88 172√85 −352𝑠 216
− +
𝑦(𝑠) = 1695 28815 + 1695 28815 + 1695 + 1695
(2𝑠 + √85 + 11) (2𝑠 − √85 + 11) (4𝑠 2 + 9) (4𝑠 2 + 9)
88 11 172 √85
(𝑠 + 2 ) ( 2 )
1695 339√85
𝑦(𝑠) = 2 + 2
11 2 √85 11 2 √85
(𝑠 + 2 ) − ( 2 ) (𝑠 + 2 ) − ( 2 )
352𝑠 12 3
∙( )
− 1695 + 565 2
2 3 2 2 3 2
(𝑠 + (2) ) (𝑠 + (2) )
Finding the 𝑦(𝑡) by performing inverse Laplace transform using table:
88 11 √85𝑡
𝑦(𝑡) = ℒ −1 [𝑦(𝑠)] = ( ) ∙ 𝑒 − 2 𝑡 ∙ 𝑐𝑜𝑠ℎ ( )
1695 2
172 11 √85𝑡 88 3𝑡 12 3𝑡
+( ) ∙ 𝑒 − 2 𝑡 ∙ 𝑠𝑖𝑛ℎ ( )− ∙ 𝑐𝑜𝑠 ( ) + ∙ 𝑠𝑖𝑛 ( )
339√85 2 1695 2 565 2

4) By means of numerical solution via MATLAB, evaluate and plot the time response of
the system.

By using the ODE as a input on the MATLAB, response function over time can be
obtained:

5) Determine and discuss the stability of the solution obtained via analytical (Laplace) and
numerical methods.
To determine the stability of the stability of the system analytically, using
characteristic equation from the denominator of transfer function:
1
𝐺(𝑠) = 2 → Δ𝑠 = 𝑠 2 + 11𝑠 + 9
𝑠 + 11𝑠 + 9
−√85−11 √85−11
By solving Δ𝑠 = 0, the characteristic root of the Δ𝑠, and 2
2
For numerical method, the characteristic root of the system takes place in form of
eigenvalue of the dynamic system matrix (A). Using MATLAB’s eig function, the obtained
eigenvalue of the system, are

Following the prerequisite of a stable system which is for a real characteristic root
must be a negative, 𝑟𝑒(𝑠) 𝑜𝑟 𝑒𝑖𝑔𝑣𝑎𝑙 < 0. Thus, with the obtained characteristic root for this
problem, it is suggested that the system is a stable system.

6) Decrease the damping, C, by 50% from the original value, solve numerically.

7) Increase the damping, C, by 50% from the original value, solve numerically.

8) Plot all responses of various C values (inc. the original one), evaluate the time response.
Give your comment and analysis.
According to the graphs obtained from using numerical method for the response function and
its derivative, we can analyze that value change in C have an effect on the output response of the
dynamic system. Looking at the graph line of C = 11, which is the original value, and compare it to
50% decrease of C, the response function of the decreased C have higher amplitude with lower
wavelength resulting in higher frequency of oscillation. Different comparation result obtained
between the original and the 50% increase value in C, which showed slightly lower amplitude and
higher wavelength which means in lower frequency of oscillation. With this, we can conclude that C
have a negative correlation with the amplitude and the frequency of oscillation.

REFERENSI:

Angeles, J. (2012). Dynamic response of linear mechanical systems modeling, analysis and
Simulation. Springer US.

Chapra, S. C. (2023). Applied Numerical Methods with MATLAB for Engineers and Scientists.
McGraw Hill.

Hespanha, J. P. (2018). Linear Systems theory. Princeton University Press.

Hibbeler, R. C. (2022). Engineering mechanics: Dynamics (12th ed.). Pearson.


APPENDIX:

LAPLACE TRANSFORM CONVERSION

ℒ(𝑥̈ ) = 𝑠 2 𝑋(𝑠) − 𝑠 ∙ 𝑥(0) − 𝑥̇ (0)


ℒ(𝑥̇ ) = 𝑠 ∙ 𝑋(𝑠) − 𝑥(0)
ℒ(𝑥) = 𝑋(𝑠)
𝜔
ℒ(𝑠𝑖𝑛(𝜔𝑡)) = 2
𝑠 + 𝜔2

INVERSE LAPLACE TRANSFORM

PARTIAL FRACTION DECOMPOSITION

6
𝑦(𝑠) =
(𝑠 2 + 11𝑠 + 9)(4𝑠 2 + 9)
6
𝑦(𝑠) =
√85 11 √85 11 9
4 (𝑠 − 2 + 2 ) (𝑠 + 2 + 2 ) (𝑠 2 + 4)
3
𝑦(𝑠) = 2
√85 11 √85 11 9
(𝑠 − 2 + 2 ) (𝑠 + 2 + 2 ) (𝑠 2 + 4)

Set the PDE objectives with a set of coefficients as the numerators:


3
2 =
√85 11 √85 11 9
(𝑠 − 2 + 2 ) (𝑠 + 2 + 2 ) (𝑠 2 + 4)
𝐴𝑠 + 𝐵 𝐶 𝐷
+ +
9
𝑠 2 + 4 𝑠 + √85 + 11 𝑠 − √85 + 11
2 2 2 2

Operating the RHS by calculating the form of a single fraction:


3
2 =
√85 11 √85 11 2 9
(𝑠 − 2 + 2 ) (𝑠 + 2 + 2 ) (𝑠 + 4)

2 ((𝑠 − √85 + 11)(4𝑠 2 + 9)𝐶 + (𝑠 + √85 + 11)(4𝑠 2 + 9)𝐷 + 2(𝑠 − √85 + 11)(𝑠 + √85 + 11)(𝐴𝑠 + 𝐵))
√85 11 √85 11 9
(𝑠 − 2 + 2 ) (𝑠 + 2 + 2 ) (𝑠 2 + 4)

By eliminating both denominator at LHS and RHS:


3
= 2 ((𝑠 − √85 + 11)(4𝑠 2 + 9)𝐶 + (𝑠 + √85 + 11)(4𝑠 2 + 9)𝐷
2
+ 2(𝑠 − √85 + 11)(𝑠 + √85 + 11)(𝐴𝑠 + 𝐵))
Organizing the terms of s containing the nominator coefficient:
3 √85 11 √85 11
= 𝑠 3 (𝐴 + 𝐶 + 𝐷) + 𝑠 2 (11𝐴 + 𝐵 − 𝐶+ 𝐶+ 𝐷 + 𝐷)
2 2 2 2 2
9 9 9√85 99 9√85 99
+𝑠 (9𝐴 + 11𝐵 − 𝐶 + 𝐷) + 9𝐵 − 𝐶+ 𝐶+ 𝐷+ 𝐷
2 2 8 8 8 8

Thus we can constructed four system of linear equation of each nominator coefficient:
𝐴+𝐶+𝐷 =0
√85 11 √85 11
11𝐴 + 𝐵 − 𝐶+ 𝐶+ 𝐷+ 𝐷=0
2 2 2 2
9 9
𝐴 + 11𝐵 − 𝐶 + 𝐷 = 0
2 2
9√85 99 9√85 99
9𝐵 − 𝐶+ 𝐶+ 𝐷+ 𝐷=0
8 8 8 8
Using calculator to solve the system of equations, we get that
88 18 44 86√85 44 86√85
𝐴=− ,𝐵 = ,𝐶 = − ,𝐷 = +
1695 1695 1695 28815 1695 28815

To conclude, the PFD of the response function is


88 172√85 88 172√85 −352𝑠 216
− +
1695 28815 + 1695 28815 + 1695 + 1695
(2𝑠 + √85 + 11) (2𝑠 − √85 + 11) (4𝑠 2 + 9) (4𝑠 2 + 9)

INVERSE LAPLACE TRANSFORM CONVERSION

𝑠−𝑎
ℒ −1 ( ) = 𝑒 𝑎𝑡 ∙ 𝑐𝑜𝑠ℎ(𝑏𝑡)
(𝑠 − 𝑎)2 − (𝑏)2
𝑏
ℒ −1 ( ) = 𝑒 𝑎𝑡 ∙ 𝑠𝑖𝑛(𝑏𝑡)
(𝑠 − 𝑎)2 − (𝑏)2
𝑠
ℒ −1 ( 2 ) = 𝑐𝑜𝑠(𝑎𝑡)
(𝑠) − (𝑎)2

𝑎
ℒ −1 ( 2 ) = 𝑠𝑖𝑛(𝑎𝑡)
(𝑠) − (𝑎)2

ANALYTICAL SOLUTION OUTPUT


1st ODE
C = 11
𝑦(𝑡) = 𝑒𝑥𝑝((𝑡 ∗ (85^(1/2) − 11))/2) ∗ (85^(1/2)/18 + 11/18) ∗ ((3 ∗ 85^(1/2)
∗ (85^(1/2) − 11))/(85 ∗ (22 ∗ 85^(1/2) − 215)) − (𝑒𝑥𝑝((11 ∗ 𝑡)/2
− (85^(1/2) ∗ 𝑡)/2) ∗ ((11 ∗ 85^(1/2))/170 − 1/2) ∗ ((3 ∗ 𝑐𝑜𝑠((3 ∗ 𝑡)/2))/2
+ 𝑠𝑖𝑛((3 ∗ 𝑡)/2) ∗ (85^(1/2)/2 − 11/2)))/((85^(1/2)/2 − 11/2)^2
+ 9/4)) + 𝑒𝑥𝑝(−(𝑡 ∗ (85^(1/2) + 11))/2) ∗ ((27 ∗ (3487 ∗ 85^(1/2)
− 31535))/(17 ∗ (22 ∗ 85^(1/2) − 215)^2 ∗ (22 ∗ 85^(1/2) + 215))
− (𝑒𝑥𝑝((11 ∗ 𝑡)/2 + (85^(1/2) ∗ 𝑡)/2) ∗ ((11 ∗ 85^(1/2))/170 + 1/2) ∗ ((3
∗ 𝑐𝑜𝑠((3 ∗ 𝑡)/2))/2 − 𝑠𝑖𝑛((3 ∗ 𝑡)/2) ∗ (85^(1/2)/2 + 11/2)))/((85^(1/2)/2
+ 11/2)^2 + 9/4)) ∗ (85^(1/2)/18 − 11/18)
C = 5.5
𝑦(𝑡) = ((11 ∗ 𝑒𝑥𝑝(−(11 ∗ 𝑡)/4) ∗ 𝑠𝑖𝑛((23^(1/2) ∗ 𝑡)/4))/36 + (23^(1/2) ∗ 𝑒𝑥𝑝(−(11
∗ 𝑡)/4) ∗ 𝑐𝑜𝑠((23^(1/2) ∗ 𝑡)/4))/36) ∗ ((165 ∗ 23^(1/2))/2323 − (𝑒𝑥𝑝((11
∗ 𝑡)/4) ∗ (207 ∗ 𝑐𝑜𝑠((3 ∗ 𝑡)/2) ∗ 𝑠𝑖𝑛((23^(1/2) ∗ 𝑡)/4) + 253 ∗ 𝑠𝑖𝑛((3 ∗ 𝑡)/2)
∗ 𝑠𝑖𝑛((23^(1/2) ∗ 𝑡)/4) + 165 ∗ 23^(1/2) ∗ 𝑐𝑜𝑠((3 ∗ 𝑡)/2) ∗ 𝑐𝑜𝑠((23^(1/2)
∗ 𝑡)/4) − 337 ∗ 23^(1/2) ∗ 𝑠𝑖𝑛((3 ∗ 𝑡)/2) ∗ 𝑐𝑜𝑠((23^(1/2) ∗ 𝑡)/4)))/2323)
− ((𝑒𝑥𝑝((11 ∗ 𝑡)/4) ∗ (207 ∗ 𝑐𝑜𝑠((3 ∗ 𝑡)/2) ∗ 𝑐𝑜𝑠((23^(1/2) ∗ 𝑡)/4) + 253
∗ 𝑠𝑖𝑛((3 ∗ 𝑡)/2) ∗ 𝑐𝑜𝑠((23^(1/2) ∗ 𝑡)/4) − 165 ∗ 23^(1/2) ∗ 𝑐𝑜𝑠((3 ∗ 𝑡)/2)
∗ 𝑠𝑖𝑛((23^(1/2) ∗ 𝑡)/4) + 337 ∗ 23^(1/2) ∗ 𝑠𝑖𝑛((3 ∗ 𝑡)/2) ∗ 𝑠𝑖𝑛((23^(1/2)
∗ 𝑡)/4)))/2323 − 9/101) ∗ ((11 ∗ 𝑒𝑥𝑝(−(11 ∗ 𝑡)/4) ∗ 𝑐𝑜𝑠((23^(1/2)
∗ 𝑡)/4))/36 − (23^(1/2) ∗ 𝑒𝑥𝑝(−(11 ∗ 𝑡)/4) ∗ 𝑠𝑖𝑛((23^(1/2) ∗ 𝑡)/4))/36
C = 16.5
𝑦(𝑡) = 𝑒𝑥𝑝((3 ∗ 𝑡 ∗ (105^(1/2) − 11))/4) ∗ (105^(1/2)/12 + 11/12) ∗ ((2 ∗ 105^(1/2)
∗ (105^(1/2) − 11))/(315 ∗ (11 ∗ 105^(1/2) − 115)) − (𝑒𝑥𝑝((33 ∗ 𝑡)/4
− (3 ∗ 105^(1/2) ∗ 𝑡)/4) ∗ ((11 ∗ 105^(1/2))/210 − 1/2) ∗ ((3 ∗ 𝑐𝑜𝑠((3
∗ 𝑡)/2))/2 + 𝑠𝑖𝑛((3 ∗ 𝑡)/2) ∗ ((3 ∗ 105^(1/2))/4 − 33/4)))/(((3
∗ 105^(1/2))/4 − 33/4)^2 + 9/4)) + 𝑒𝑥𝑝(−(3 ∗ 𝑡 ∗ (105^(1/2) + 11))/4)
∗ ((8 ∗ (979 ∗ 105^(1/2) − 9975))/(63 ∗ (11 ∗ 105^(1/2) − 115)^2 ∗ (11
∗ 105^(1/2) + 115)) − (𝑒𝑥𝑝((33 ∗ 𝑡)/4 + (3 ∗ 105^(1/2) ∗ 𝑡)/4) ∗ ((11
∗ 105^(1/2))/210 + 1/2) ∗ ((3 ∗ 𝑐𝑜𝑠((3 ∗ 𝑡)/2))/2 − 𝑠𝑖𝑛((3 ∗ 𝑡)/2) ∗ ((3
∗ 105^(1/2))/4 + 33/4)))/(((3 ∗ 105^(1/2))/4 + 33/4)^2 + 9/4))
∗ (105^(1/2)/12 − 11/12)

2nd ODE
C = 11
𝑑𝑦(𝑡)
= 𝑒𝑥𝑝(−(𝑡 ∗ (85^(1/2) + 11))/2) ∗ ((27 ∗ (3487 ∗ 85^(1/2) − 31535))/(17 ∗ (22
𝑑𝑡
∗ 85^(1/2) − 215)^2 ∗ (22 ∗ 85^(1/2) + 215)) − (𝑒𝑥𝑝((11 ∗ 𝑡)/2
+ (85^(1/2) ∗ 𝑡)/2) ∗ ((11 ∗ 85^(1/2))/170 + 1/2) ∗ ((3 ∗ 𝑐𝑜𝑠((3 ∗ 𝑡)/2))/2
− 𝑠𝑖𝑛((3 ∗ 𝑡)/2) ∗ (85^(1/2)/2 + 11/2)))/((85^(1/2)/2 + 11/2)^2
+ 9/4)) − 𝑒𝑥𝑝((𝑡 ∗ (85^(1/2) − 11))/2) ∗ ((3 ∗ 85^(1/2) ∗ (85^(1/2)
− 11))/(85 ∗ (22 ∗ 85^(1/2) − 215)) − (𝑒𝑥𝑝((11 ∗ 𝑡)/2 − (85^(1/2) ∗ 𝑡)/2)
∗ ((11 ∗ 85^(1/2))/170 − 1/2) ∗ ((3 ∗ 𝑐𝑜𝑠((3 ∗ 𝑡)/2))/2 + 𝑠𝑖𝑛((3 ∗ 𝑡)/2)
∗ (85^(1/2)/2 − 11/2)))/((85^(1/2)/2 − 11/2)^2 + 9/4))
C = 5.5
𝑑𝑦(𝑡)
= 𝑒𝑥𝑝(−(11 ∗ 𝑡)/4) ∗ 𝑐𝑜𝑠((23^(1/2) ∗ 𝑡)/4) ∗ ((𝑒𝑥𝑝((11 ∗ 𝑡)/4) ∗ (207 ∗ 𝑐𝑜𝑠((3
𝑑𝑡
∗ 𝑡)/2) ∗ 𝑐𝑜𝑠((23^(1/2) ∗ 𝑡)/4) + 253 ∗ 𝑠𝑖𝑛((3 ∗ 𝑡)/2) ∗ 𝑐𝑜𝑠((23^(1/2) ∗ 𝑡)/4)
− 165 ∗ 23^(1/2) ∗ 𝑐𝑜𝑠((3 ∗ 𝑡)/2) ∗ 𝑠𝑖𝑛((23^(1/2) ∗ 𝑡)/4) + 337 ∗ 23^(1/2)
∗ 𝑠𝑖𝑛((3 ∗ 𝑡)/2) ∗ 𝑠𝑖𝑛((23^(1/2) ∗ 𝑡)/4)))/2323 − 9/101) − 𝑒𝑥𝑝(−(11 ∗ 𝑡)/4)
∗ 𝑠𝑖𝑛((23^(1/2) ∗ 𝑡)/4) ∗ ((165 ∗ 23^(1/2))/2323 − (𝑒𝑥𝑝((11 ∗ 𝑡)/4) ∗ (207
∗ 𝑐𝑜𝑠((3 ∗ 𝑡)/2) ∗ 𝑠𝑖𝑛((23^(1/2) ∗ 𝑡)/4) + 253 ∗ 𝑠𝑖𝑛((3 ∗ 𝑡)/2)
∗ 𝑠𝑖𝑛((23^(1/2) ∗ 𝑡)/4) + 165 ∗ 23^(1/2) ∗ 𝑐𝑜𝑠((3 ∗ 𝑡)/2) ∗ 𝑐𝑜𝑠((23^(1/2)
∗ 𝑡)/4) − 337 ∗ 23^(1/2) ∗ 𝑠𝑖𝑛((3 ∗ 𝑡)/2) ∗ 𝑐𝑜𝑠((23^(1/2) ∗ 𝑡)/4)))/2323)
C = 16.5
𝑑𝑦(𝑡)
= 𝑒𝑥𝑝(−(3 ∗ 𝑡 ∗ (105^(1/2) + 11))/4) ∗ ((8 ∗ (979 ∗ 105^(1/2) − 9975))/(63 ∗ (11
𝑑𝑡
∗ 105^(1/2) − 115)^2 ∗ (11 ∗ 105^(1/2) + 115)) − (𝑒𝑥𝑝((33 ∗ 𝑡)/4 + (3
∗ 105^(1/2) ∗ 𝑡)/4) ∗ ((11 ∗ 105^(1/2))/210 + 1/2) ∗ ((3 ∗ 𝑐𝑜𝑠((3 ∗ 𝑡)/2))/2
− 𝑠𝑖𝑛((3 ∗ 𝑡)/2) ∗ ((3 ∗ 105^(1/2))/4 + 33/4)))/(((3 ∗ 105^(1/2))/4
+ 33/4)^2 + 9/4)) − 𝑒𝑥𝑝((3 ∗ 𝑡 ∗ (105^(1/2) − 11))/4) ∗ ((2 ∗ 105^(1/2)
∗ (105^(1/2) − 11))/(315 ∗ (11 ∗ 105^(1/2) − 115)) − (𝑒𝑥𝑝((33 ∗ 𝑡)/4
− (3 ∗ 105^(1/2) ∗ 𝑡)/4) ∗ ((11 ∗ 105^(1/2))/210 − 1/2) ∗ ((3 ∗ 𝑐𝑜𝑠((3
∗ 𝑡)/2))/2 + 𝑠𝑖𝑛((3 ∗ 𝑡)/2) ∗ ((3 ∗ 105^(1/2))/4 − 33/4)))/(((3
∗ 105^(1/2))/4 − 33/4)^2 + 9/4))

MATLAB SUBROUTINE

clear,clc,clf
%% Define all inputs and variables
NIM_num = input("Insert your NIM = ","s"); % to find values of
coeff M, C, K, and w.
fprintf("\n");
M=1+str2double(NIM_num(6));
C0=3+str2double(NIM_num(4))+str2double(NIM_num(7));
C1=C0-0.5*C0; % as the problem
requested
C2=C0+0.5*C0;
K=6+str2double(NIM_num(5))+str2double(NIM_num(8));
w=0.5*(K/M)^0.5;
F0=1;

%% Analytical Solution
% Define the values of C for looping
C_coeff = [C0, C1, C2];
numC_coeff = numel(C_coeff);

for i = 1:numC_coeff
C = C_coeff(i);
syms x1(t) x2(t)
eqns= [diff(x1,t)==x2, diff(x2,t)==(F0*sin(w*t)-K*x1-
C*x2)/M]; % Defines system of first-order ODE
init_conds=[x1(0)==0, x2(0)==0]; %initial conds
sols= dsolve (eqns, init_conds); %analytical solutions to the
ODE system
sol_y1 = sols.x1;
sol_y2 = sols.x2;
fprintf("Analytical solution for 1st ODE C=%.2f: \n",C);
disp(sol_y1);
fprintf ("Analytical solution for 2nd ODE C=%.2f: \n",C);
disp(sol_y2);
end
%% Numerical Solution Runge-Kutta
tspan= [0 25]; % span of t observed
X0 = [0 0];
% Plot y(t) and dy(t)/dt for all C
figure(1)
subplot(2, 1, 1);
hold on

for i = 1:numC_coeff
C = C_coeff(i);
[tt, Y] = ode45(@(tt,Y)odefun(tt, Y, M, C, K, F0, w), tspan,
X0);

plot(tt, Y(:, 1), "-^", "DisplayName", sprintf("solusi y(t)


dengan C=%.2f", C));
end

title("Fungsi y(t)");
xlabel("t (s) ");
ylabel("y (m) ");
legend("show","FontSize", 10);

subplot(2, 1, 2);
hold on

for i = 1:numC_coeff
C = C_coeff(i);
[tt, Y] = ode45(@(tt,Y)odefun(tt, Y, M, C, K, F0, w), tspan,
X0);

plot(tt, Y(:, 2), "-o", "DisplayName", sprintf("solusi dy(t)/dt


dengan C=%.2f", C));
end

title("Fungsi dy(t)/dt");
xlabel("t (s) ");
ylabel("dy/dt (m/s)");
legend("show","FontSize", 10)

% Plot the results for each value of C in separate subplots


figure(2)
for i = 1:numC_coeff
subplot(3, 1, i);
C = C_coeff(i);
[tt, Y] = ode45(@(tt,Y)odefun(tt, Y, M, C, K, F0, w), tspan,
X0);
hold on

plot(tt, Y(:, 1), "-b", "DisplayName", sprintf("solusi y(t)


dengan C=%.2f", C));
plot(tt, Y(:, 2), '-r', "DisplayName", sprintf("solusi dy(t)/dt
dengan C=%.2f", C));
ylim([-0.15, 0.15]);
xlabel("t (s)", "FontSize", 14);
ylabel("y (m) & dy/dt (m/s) ", "FontSize", 14);
legend("show","FontSize", 14);
title(sprintf("Fungsi y(t) & dy(t)/dt dengan C=%.2f", C));
end
%% Function
function dYdt = odefun(tt, Y, M, C, K, F, w)
dYdt = zeros(2, 1);
dYdt(1) = Y(2);
dYdt(2) = (F * sin(w * tt) - K * Y(1) - C * Y(2)) / M;
end

You might also like