Professional Documents
Culture Documents
, MEP-ECE - Instructor
Laboratory Activities in EC 117/ES 117 | Engr. Victorino R. Tobias, Jr., MEP-ECE - Instructor
Activity 2
Write a Matlab code to determine the Inverse Laplace Transform of the following:
4. a/s2+a2
6. 2/(s+2)2
5.
Note: Write your Matlab codes at the back of this page together with the output.
s 4 3s 3 15s 2 2s 9
To enter this into Matlab, just enter it as a vector in the following manner
x = [1 3 -15 -2 9]
x=
1 3 -15 -2 9
Matlab can interpret a vector of length (n+1) as an nth order polynomial. Thus, if your polynomial is
missing any coefficients, you must enter zeros in the appropriate place in the vector. For example,
s4 1
would be represented in Matlab as:
y = [1 0 0 0 1]
You can find the value of a polynomial using the polyval( ) function. For example, to find the value
of the above polynomial at s=2,
z = polyval([1 0 0 0 1], 2)
z=
17
Laboratory Activities in EC 117/ES 117 | Engr. Victorino R. Tobias, Jr., MEP-ECE - Instructor
You can also extract the roots of a polynomial. This is useful when you have a high-order
polynomial such as
s 4 3s 3 15s 2 2s 9
Finding the roots would be as easy as entering the following command;
roots([1 3 -15 -2 9])
ans =
-5.5745
2.5836
-0.7951
0.7860
You can also construct a polynomial using poly( ) function.
r = [-1, -2];
p = poly(r);
ans = 1 3 2
You can interpret that the resulting polynomial is given by
s 2 3s 2
Activity 3
1. Write a Matlab code to store the 7th order polynomial:
s7 + 2s6 + s5 + 2s4 + 4s3 + 8s2 + 4s + 2
Also, write a code to determine the value of the polynomial when s = -2.
2. What is the code to determine the roots of the polynomial in no. 1? Record your result.
3. The roots of a certain polynomial are :
0
0.9974 + 1.9667i
0.9974 - 1.9667i
-0.5103 + 2.1782i
-0.5103 - 2.1782i
-1.7668
-1.1036 + 0.9600i
-1.1036 - 0.9600i
Write a Matlab code to display the polynomial.
Note: Write your Matlab codes at the back of this page together with the output.
3
Laboratory Activities in EC 117/ES 117 | Engr. Victorino R. Tobias, Jr., MEP-ECE - Instructor
Example
You would like to find the inverse Laplace Transform of F(s) given by
F ( s)
s 2 12
s 3 5s 2 6 s
For this you have to decompose F(s) into simple terms uing partial fraction expansion:
Matlab code
num =[1 0 12];
den = [1 5 6 0];
Laboratory Activities in EC 117/ES 117 | Engr. Victorino R. Tobias, Jr., MEP-ECE - Instructor
Example
Find the inverse Laplace Transform of
I L ( s)
384 10 5
s( s 2 64,000s 16 108 )
In order to find it, we need to perform partial fraction expansion. The following Matlab M-File
provides us with the partial fraction expansion coefficients.
Matlab code
num = [38400000];
den = [1 64000 1600000000 0];
[r, p, k] = residue(num, den)
24 10 3
20 10 3 126.87
20 10 3 126.87
I L ( s)
s
s 32,000 j 24,000 s 32,000 j 24,000
The above results indicate that we have the following expression for I L (s) : Simple manipulation
shown in the class ends up with the current in the time domain :
Laboratory Activities in EC 117/ES 117 | Engr. Victorino R. Tobias, Jr., MEP-ECE - Instructor
Activity 4
Write a Matlab code to determine the poles of the function below. After which, based from the
poles obtained, find the inverse Laplace transform of the function.
Note: Write your Matlab codes and your answer at the back of this page together with the output.
G( s)
10
s 2s 10
2
Laboratory Activities in EC 117/ES 117 | Engr. Victorino R. Tobias, Jr., MEP-ECE - Instructor
t=[0:0.1:10]';
num=10;
den=[1 2 10];
sys = tf(num,den);
y_i = impulse(sys,t);
y_s = step(sys,t);
title('Output of Example')
subplot(2,1,1), plot(t,y_i), ylabel('Impulse response') % plot impulse response
subplot(2,1,2), plot(t,y_s), ylabel('Step response') % plot step response
xlabel('time in seconds')
This gives you the plot below:
In order to compute the response to ramp function and noise, we can do the following procedures.
ramp=t;
noise=rand(101,1);
y_g = lsim(sys,ramp,t);
y_n = lsim(sys,noise,t);
figure
7
Laboratory Activities in EC 117/ES 117 | Engr. Victorino R. Tobias, Jr., MEP-ECE - Instructor
Activity 5
1. Write a Matlab code to determine the impulse and step response from t = 0 to t = 10 of
the system with the following transfer function. Sketch the all the figures generated.
2. Write a Matlab code to generate a ramp and noise signals and sketch the response of the
system with these inputs.
Note: Write your Matlab codes and your answer at the back of this page together with the output.