Matlab 2
Matlab 2
Matlab 2
Submitted to:
Engr. Johaimen M. Omar
Submitted by:
Rauda Nano Antol
1.1 OBJECTIVES
To learn to use MATLAB to (1) find Laplace transforms for time functions, (2) find time functions from
Laplace transforms, (3) create LTI transfer functions from symbolic transfer functions, and (4) perform
solutions of symbolic simultaneous equations.
1.3 PRELAB
1. Using a hand calculation, find the Laplace transform of:
𝑓 (𝑡) = 0.0075 − 0.00034𝑒−2.5𝑡 cos(22𝑡) + 0.087𝑒−2.5𝑡 sin(22𝑡) − 0.0072𝑒−8𝑡
Solution 1:
Knowing that
ℒ {𝑓 (𝑡)} = 𝐹 (𝑠)
1
ℒ {1} =
𝑠
−𝑎𝑡 𝑠+𝑎
ℒ 𝑒 cos 𝜔𝑡 =
(𝑠 + 𝑎)2 + 𝜔2
𝜔
ℒ 𝑒−𝑎𝑡 sin 𝜔𝑡 =
(𝑠 + 𝑎)2 + 𝜔2
1
ℒ 𝑒𝑎𝑡 =
𝑠−𝑎
Thus,
1 𝑠 + 2.5 22 1
𝐹 (𝑠) = 0.0075 − 0.00034 2 2
+ 0.087 2 2
− 0.0072
𝑠 (𝑠 + 2.5) + 22 (𝑠 + 2.5) + 22 𝑠 + 8
1 2 1 0
18
∆𝐵 = 180 30 8 1
142 0 8
800 210 0 0
2 1 0 1 1 0
∆𝐵 = −800 30 8 1 + 210 18 8 1 − 0 + 0
142 0 8 180 0 8
∆𝐵 = −800[2(64) − 30(8) + 142(1)] + 210[64 − 18(8) + 180(1)]
∆𝐵 = −24 000 + 21 000
∆𝐵 = −3000
1 1 2 0
18
∆𝐶 = 180 10 30 1
100 142 8
800 0 210 0
1 2 0 1 1 0
∆𝐶 = −800 10 30 1 + 0 − 210 18 10 1 + 0
100 142 8 180 100 8
∆𝐶 = −800[(240 − 142) − 10(16) + 100(2)] − 210[(80 − 100) − 18(8) + 180(1)]
∆𝐶 = −110 400 − 3360
∆𝐶 = −113 760
1 1 1 2
18 10 8
∆𝐷 = 180 100 0 142 30
800 0 0 210
1 1 2 1 1 1
∆𝐷 = −800 10 8 30 + 0 − 0 + 210 18 10 8
100 0 142 180 100 0
∆𝐷 = −800[1136 − 10(142) + 100(30 − 16)] + 210[−800 − 18(−100) + 180(8 − 10)]
∆𝐷 = −892 800 + 134 400
∆𝐷 = −758 400
Then,
∆𝐵 −3000 5
𝐵= = =
∆ −67 200 112
∆𝐶 −113 760 237
𝐶= = =
∆ −67 200 140
∆ −758 400 79
𝐷= 𝐷= =
∆ −67 200 7
When the partial fraction is formed, arrange algebraically that satisfies inverse Laplace transform.
21 5 237𝑠 + 79
80 112 140 7
𝐹 (𝑠) = + + 2
𝑠 𝑠 + 8 𝑠 + 10𝑠 + 100
21 5 237𝑠 + 1580
𝐹 (𝑠) = + +
80𝑠 112(𝑠 + 8) 140(𝑠2 + 10𝑠 + 25 + 75)
21 5 237𝑠 + 1185 + 395
𝐹 (𝑠) = + +
80𝑠 112(𝑠 + 8) 140 (𝑠 + 5)2 + (√75)2
21 5 237(𝑠 + 5) 395
𝐹 (𝑠) = + + +
80𝑠 112(𝑠 + 8) 140 (𝑠 + 5)2 + (5√3)2 140 (𝑠 + 5)2 + (5√3)2
21 5 237(𝑠 + 5) 79 5√3
𝐹 (𝑠) = + + + ·
80𝑠 112(𝑠 + 8) 140 (𝑠 + 5)2 + (5√3)2 140√3 (𝑠 + 5)2 + (5√3)2
𝑓 (𝑡) = ℒ −1 {𝐹 (𝑠)}
⎧ ⎫
21 −1 1 5 −1 1 237 −1 ⎪ 𝑠+5 ⎪
𝑓 (𝑡) = ℒ + ℒ + ℒ ⎨ ⎬
80 𝑠 112 𝑠+8 140 ⎪ 2 2 ⎪
⎩ (𝑠 + 5) + (5√3) ⎭
⎧
⎪ 5√3 ⎫
⎪
79
+ ℒ −1 ⎨ ⎬
140√3 ⎪ 2 2 ⎪
⎩ (𝑠 + 5) + (5√3) ⎭
21 5 −8𝑡 237 −5𝑡 79
𝑓 (𝑡) = + 𝑒 + 𝑒 cos(5√3𝑡) + 𝑒−5𝑡 sin(5√3𝑡)
80 112 140 140√3
𝑓 (𝑡) = 0.2625 + 0.0446𝑒−8𝑡 + 1.6929𝑒−5𝑡 cos(8.6603𝑡) + 0.3258𝑒−5𝑡 sin(8.6603𝑡)
3. Use a hand calculation to solve the circuit for the Laplace transforms of the loop currents shown in
Fig. 2.1.
Figure 2.1
Solution 3:
At mesh 𝐼1 (𝑠),
3 5
= 𝑠 + + (5 + 2) 𝐼1 (𝑠) − (𝑠 + 2)𝐼2 (𝑠) − 5𝐼3 (𝑠)
𝑠 𝑠
3 5
= 𝑠 + + 7 𝐼1 (𝑠) − (𝑠 + 2)𝐼2 (𝑠) − 5𝐼3 (𝑠)
𝑠 𝑠
At mesh 𝐼2 (𝑠),
3
0 = −(𝑠 + 2)𝐼1 (𝑠) + (1 + 1)𝑠 + + (2 + 2) 𝐼2 (𝑠) − (𝑠 + 2)𝐼3 (𝑠)
𝑠
3
0 = −(𝑠 + 2)𝐼1 (𝑠) + 2𝑠 + + 4 𝐼2 (𝑠) − (𝑠 + 2)𝐼3 (𝑠)
𝑠
At mesh 𝐼3 (𝑠),
4
0 = −5𝐼1 (𝑠) − (𝑠 + 2)𝐼2 (𝑠) + 𝑠 + + (5 + 2 + 1) 𝐼3 (𝑠)
𝑠
4
0 = −5𝐼1 (𝑠) − (𝑠 + 2)𝐼2 (𝑠) + 𝑠 + + 8 𝐼3 (𝑠)
𝑠
Form the system into matrix and use Cramer’s rule.
|𝑠 + 5 + 7 −(𝑠 + 2) −5 ||
| 𝑠
| 3 |
∆ = | −(𝑠 + 2) 2𝑠 + + 4 −(𝑠 + 2) |
| 𝑠 |
| −5 4
| −(𝑠 + 2) 𝑠 + + 8||
𝑠
5 3 4
∆= 𝑠+ +7 2𝑠 + + 4 𝑠 + + 8 − (𝑠 + 2)2
𝑠 𝑠 𝑠
4 3
+ (𝑠 + 2) −(𝑠 + 2) 𝑠 + + 8 − 5(𝑠 + 2) − 5 (𝑠 + 2)2 + 5 2𝑠 + + 4
𝑠 𝑠
𝑠2 + 7𝑠 + 5 𝑠4 + 16𝑠3 + 39𝑠2 + 40𝑠 + 12 −𝑠3 − 15𝑠2 − 30𝑠 − 8
∆= + (𝑠 + 2)
𝑠 𝑠2 𝑠
3 2
𝑠 + 14𝑠 + 24𝑠 + 15
−5
𝑠
𝑠 + 23𝑠 + 156𝑠 + 393𝑠 + 487𝑠2 + 284𝑠 + 60
6 3 4 3
𝑠4 + 22𝑠3 + 130𝑠2 + 288𝑠 + 91
∆= −
𝑠3 𝑠
𝑠 + 23𝑠 + 156𝑠 + 393𝑠 + 487𝑠 + 284𝑠 + 60 − 𝑠 𝑠 + 22𝑠 + 130𝑠2 + 288𝑠 + 91
6 3 4 3 2 2 4 3
∆=
𝑠3
𝑠6 + 23𝑠5 + 156𝑠4 + 393𝑠3 + 487𝑠2 + 284𝑠 + 60 − 𝑠6 + 22𝑠5 + 130𝑠4 + 288𝑠3 + 91𝑠2
∆=
𝑠3
5 4 3 2
𝑠 + 26𝑠 + 205𝑠 + 396𝑠 + 284𝑠 + 60
∆=
𝑠3
|3 −(𝑠 + 2) −5 |
|𝑠 |
| 3 |
∆1 = |0 2𝑠 + + 4 −(𝑠 + 2) |
| 𝑠 |
|0 −(𝑠 + 2) 4
| 𝑠 + + 8||
𝑠
3 3 4
∆1 = 2𝑠 + + 4 𝑠 + + 8 − (𝑠 + 2)2 − 0 + 0
𝑠 𝑠 𝑠
3 12 40
∆1 = 2𝑠 + 20𝑠 + 2 + + 43 − (𝑠2 + 4𝑠 + 4)
2
𝑠 𝑠 𝑠
3 2 12 40
∆1 = 𝑠 + 16𝑠 + 2 + + 39
𝑠 𝑠 𝑠
3 𝑠4 + 16𝑠3 + 39𝑠2 + 40𝑠 + 12
∆1 =
𝑠 𝑠2
3(𝑠4 + 16𝑠3 + 39𝑠2 + 40𝑠 + 12)
∆1 =
𝑠3
|𝑠 + 5 + 7 3 −5 ||
| 𝑠 𝑠
∆2 = | −(𝑠 + 2) 0 −(𝑠 + 2) |
| 4 |
|| −5 0 𝑠 + + 8||
𝑠
3 4
∆2 = − −(𝑠 + 2) 𝑠 + + 8 − 5(𝑠 + 2) + 0 − 0
𝑠 𝑠
3 8
∆2 = − −𝑠2 − 15𝑠 − 30 −
𝑠 𝑠
3 𝑠3 + 15𝑠2 + 30𝑠 + 8
∆2 =
𝑠 𝑠
3 2
3(𝑠 + 15𝑠 + 30𝑠 + 8)
∆2 =
𝑠2
|𝑠 + 5 + 7 −(𝑠 + 2) 3|
| 𝑠 𝑠|
∆3 = | 3 |
| −(𝑠 + 2) 2𝑠 + + 4 0|
| 𝑠 |
| −5 −(𝑠 + 2) 0|
3 3
∆3 = (𝑠 + 2)2 − 5 2𝑠 + + 4 − 0 + 0
𝑠 𝑠
3 2 15
∆3 = (𝑠 + 4𝑠 + 4) − 10𝑠 + + 20
𝑠 𝑠
3 2 15
∆3 = 𝑠 + 14𝑠 + 24 +
𝑠 𝑠
3 𝑠3 + 14𝑠2 + 24𝑠 + 15
∆3 =
𝑠 𝑠
3 2
3(𝑠 + 14𝑠 + 24𝑠 + 15)
∆3 =
𝑠2
b. Generate symbolically F(s) shown in Prelab 2. Obtain your result symbolically in both factored and
polynomial forms.
Program and Result:
c. Find the Laplace transform of f(t) shown in Prelab 1.
Program and Result:
1.5 POSTLAB
1. For a given time function, how can you determine its Laplace transform using MATLAB?
Use laplace() when programming the given time function. In addition, if you want to change from
irrational or rational numbers to decimal numbers in Laplace transform, use vpa().
2. Suppose you have the Laplace transform of a signal. How can you use MATLAB to obtain the
corresponding time function? Are there any limitations to this process?
To obtain the corresponding time function, use ilaplace() for inverse Laplace transform. In addition, if
you want to change from irrational or rational numbers to decimal numbers in time function, use vpa().
There are no further explanations to predict those limitations since MATLAB is a vast mathematical
application tool to perform complicated calculations.
3. In solving a system of simultaneous equations symbolically using MATLAB, what are some important
considerations to keep in mind? How can you check your solutions for correctness?
The system of simultaneous equations can be symbolically converted into matrix especially when
determining the unknown coefficients or variables. For instance, if you know how to apply Cramer’s rule
by hand solving, then you can program this method in MATLAB. To check the correctness of the
solutions, you must first understand the algorithm from hand solving to programming, verify the given
variables, and investigate thoroughly the program if everything makes sense.
4. Can you demonstrate how to use MATLAB to solve a system of simultaneous equations symbolically?
What are some common errors that can occur during this process, and how can you avoid them?
Yes. Again, MATLAB is much easier to demonstrate a system of simultaneous equations by converting to
matrix. The most common errors in this process are some elements in the matrix that are unmatched such
as negative or positive signs and polynomials, and the number of elements required. Although we commit
mistakes, we can debug after making the program at first until we are satisfied it is correct. For this
reason, you must also understand the programming language of MATLAB.
5. How can you use MATLAB to verify the correctness of our Laplace transform calculations and solutions
to simultaneous equations? Are there any built-in functions or tools that can help you with this task?
To verify this correctness, it is an optional to compare between MATLAB results and your hand solving
in Laplace transform, yet this is time consuming. It depends on your perspective how you are convenient
to solve Laplace transform calculations. However, fascinating that you are good at programming without
the need of prolonged hand solving and then let MATLAB do the job in no time. There are more things to
explore in MATLAB beyond this experiment but for the meantime, I have learned the basics.