0% found this document useful (0 votes)
11 views29 pages

Feedback Lab Scripts

The document details the analysis of first and second-order systems using MATLAB, including the determination of system responses to various inputs and the comparison of manual calculations with MATLAB outputs. It covers impulse and step responses, pole-zero mapping, and the calculation of system characteristics such as damping ratios and natural frequencies. Additionally, it provides MATLAB commands for generating plots and analyzing system behavior, culminating in the creation of a MATLAB function for second-order system analysis.
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)
11 views29 pages

Feedback Lab Scripts

The document details the analysis of first and second-order systems using MATLAB, including the determination of system responses to various inputs and the comparison of manual calculations with MATLAB outputs. It covers impulse and step responses, pole-zero mapping, and the calculation of system characteristics such as damping ratios and natural frequencies. Additionally, it provides MATLAB commands for generating plots and analyzing system behavior, culminating in the creation of a MATLAB function for second-order system analysis.
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

Activity 3 - TIME RESPONSE OF FIRST ORDER SYSTЕМ

1.​ Determine the response c(t) of the system G(s) = 4/(s+4) to the
input R(s) =1 or r(t) = 1 (impulse).

4
C(s): (𝑠+4)
c(t): 4e-4t
2.​ Using the plot command, plot c(t) from 0 to 1.5 seconds.

Matlab Command:
%Item 1
%C(s) = 4/(s+4)
%c(t) = 4e^{-4t}

%Item 2
t = 0:0.01:1.5;
c = 4 * exp(-4 * t);
% Plot the response c(t) over time
figure;
plot(t, c);
xlabel('Time (s)');
ylabel('c(t)');
title('Response of the System (Manual)');
grid on;

Matlab Output:
3.​ Generate the system G(s) = 4/(s+4), and using ithe mpulse
command, take its impulse response.

Matlab Commands:
%Item 3
num = [4];
den = [1, 4];
sys = tf(num, den);
impulse(sys, 1.5)
grid on
title('Response of the System using Impulse Command')

Matlab Output:

4.​ Compare and describe the responses of items 2 and 3:


Comparing the two graphs, the manual plot and the impulse command
output are identical. This verifies that our calculated equation c(t) = 4e^{-4t} is
correct. The graph starts at a maximum value of 4 and decays to zero, as
expected for a first-order system, since the impulse energy naturally dissipates
over time.
5.​ Determine the response c(t) of the system G(s) = 4/(s+4) to the
input R(s) = 1/s or r(t) = 1.
4
C(s): 𝑠(𝑠+4)

c(t): 1 - e-4t​

Matlab Commands:
%Item 5
%C(s) = 4/(s)(s + 4)
%c(t) = 1 - e^{-4t}

%Item 6
t = 0:0.01:1.5;
c = 1 - exp(-4 * t);
% Plot the response c(t) over time
figure;
plot(t, c);
xlabel('Time (s)');
ylabel('c(t)');
title('Step Response of the System (Manual)');
grid on;
6. Plot c(t) from 0 to 1.5 seconds.
Matlab Output:
7. Using step command Plot G(s) = 4/(s+4) from 0 to 1.5 second
Matlab Commands:
%Item 7
num = [4];
den = [1, 4];
sys = tf(num, den);
step(sys, 1.5)
grid on
title('Step Response of the System using Step Command')

Matlab Output:

8. Compare and describe the responses of items 6 and 7:


Both plots look identical, starting at 0 and rising exponentially to 1. This
confirms that the MATLAB step command accurately simulates the system
without us needing to manually derive the formula c(t) = 1 - e^{-4t}. The curve
shows the transient part fading to the steady-state value of 1.
9. Determine the output put response c(t), of the system G(s) =
4/(s+4) to the input R(s) = 1/s2 or r(t) = t.
4
C(s): 2
(𝑠+4)𝑠
c(t): t - 0.25 + 0.25e -4t​

10. Plot c(t) from 0 to 2 second


Matlab Commands:
%Item 9
%C(s) = 4/(s+4)(s^2)
%c(t) = t - 0.25 + 0.25*exp(-4*t)

%Item 10
t = 0:0.01:2;
c = t - 0.25 + 0.25*exp(-4*t);
% Plot the response c(t) over time
figure;
plot(t, c);
xlabel('Time (s)');
ylabel('c(t)');
title('Ramp Response of the System (Manual)');
grid on;

Matlab Output:
11. Describe the response :
The plot shows the output becoming a straight line parallel to the input
r(t)=t. While it successfully tracks the slope, there is a constant delay or "lag"
between the input and the output. Our calculation shows this lag is 0.25
seconds, which matches the system's time constant. This basically means the
system is always playing catch-up with the ramp input.

12. Determine the response c(t) of the system G(s) = 10/(s+5) to the
3 2
input R(s) = 1/s or r(t) = (½)t .
10
C(s): 3
(𝑠+5)𝑠
c(t): t2 -0.4t+0.08-0.08e -5t​

13. Plot c(t) from 0 to 5 seconds.


Matlab Commands:
%Item 12
%C(s) = 10/(s^3)(s+5)
%c(t) = t^2 - 0.4*t + 0.08 - 0.08*exp(-5*t)

%Item 13
t = 0:0.01:5;
c = t.^2 - 0.4*t + 0.08 - 0.08*exp(-5*t);
% Plot the response c(t) over time
figure;
plot(t, c);
xlabel('Time (s)');
ylabel('c(t)');
title('Parabolic Response of the System (Manual)');
grid on;
Matlab Output:

14. Describe the response:


The response follows a curve that accelerates over time, similar to the t^2
input. This shows the system can track a constantly accelerating signal, though
there is still a significant error/lag. The exponential term in our equation dies out
quickly, so the response is dominated by the polynomial terms, leading to an
upward curve that extends indefinitely.

15. Using the ltiview command, determine the step responses of the
following systems:

G1(s) = 2/(s+2)
G2(s) = 20/(s+20)
Matlab Commands:
%Item 15
G1 = tf([2], [1 2]);
G2 = tf([20], [1 20]);
ltiview('step', G1, G2);
Matlab Output:

16. From the above step responses, determine the time constant,
rise time, and settling time of G1 and G2 by clicking a point on the
graph and dragging it to a location as specified by the required
time parameters.

System Time Constant (Sec) Rise Time (Sec) Setting Time (Sec)

G1 0.5 1.10 1.96

G2 0.05 0.11 0.196

17. Plot and label the pole-zero map of the two systems in item (15)

Matlab Commands:
%Item 17
pzmap(G1, G2);
legend('G1', 'G2');
title('Pole-Zero Map')
Matlab Output:

18 How would you relate the step response of a system to the


location of its pole?
The map shows the pole for G2 is at -20, while G1 is at -2. Since -20 is
much further to the left of the imaginary axis, the transient response decays
much faster. This visually confirms the rule: poles further to the left result in
faster, more stable systems.

19. Determine the transfer function given the step response of a


first-order system.
12.5
Transfer Function: 𝑠+5

Matlab Commands:
%Seatwork
%y_ss = 2.5
%tau = 0.2
%pole = 5
%numerator = y_ss * pole = 12.5
%transfer function = numerator/(s + a)

%TF = 12.5 / (s + 5)
num = [12.5];
den = [1 5];
G_seatwork = tf(num, den);
step(G_seatwork);
grid on;
title('Seatwork Transfer Function');
Activity 4 - STEP RESPONSE OF SECOND ORDER SYSTEMS
1. For each of the following transfer functions, find the damping
ratios and natural frequencies.

a.​Ga (s) = 100 / (s2 - 22s+100)


Matlab Commands:
Ga = tf(100, [1 -22 100]);
damp(Ga)

Matlab Output:

b.​Gb (s) = 100 / (s2 -20s+100)


Matlab Commands:
Gb = tf(100, [1 -20 100]);
damp(Gb)

Matlab Output:

c.​ Gc (s) = 100 / (s2 -10s+100)


Matlab Commands:
Gc = tf(100, [1 -10 100]);
damp(Gc)
Matlab Output:

d.​Gd (s) = 100 / (s2 +100)


Matlab Commands:
Gd = tf(100, [1 0 100]);
damp(Gd)

Matlab Output:

e.​ Ge (s) = 100 / (s2 +10s+100)


Matlab Commands:
Ge = tf(100, [1 10 100]);
damp(Ge)

Matlab Output:

f.​ Gf (s) = 100 / (s2 +20s+100)


Matlab Commands:
Gf = tf(100, [1 20 100]);
damp(Gf)
Matlab Output:

g.​Gg (s) = 100 / (s2 +22s+100)


Matlab Commands:
Gg = tf(100, [1 22 100]);
damp(Gg)

Matlab Output:

SYSTEM NATURAL FREQUENCY DAMPING RATIO

a 6.42, 15.6 -1, -1

b 10, 10 -1, -1

c 10, 10 -0.5, -0.5

d 10, 10 0, 0

e 10, 10 0.5, 0.5

f 10, 10 1, 1

g 6.42, 15.6 1, 1

2. Using different colors for each of the system in (1), use ‘ltiviewer
‘or ‘pzmap’ command to view(plot) their pole-zero maps.
Matlab Commands:
figure;
pzmap(Ga, 'r', Gb, 'y', Gc, 'c', Gd, 'b', Ge, 'g', Gf, 'm', Gg, 'w')
legend('Ga', 'Gb', 'Gc', 'Gd', 'Ge', 'Gf', 'Gg')
title('Pole-Zero Map of All Systems');
grid on;

Matlab Output:

3. Using step command, plot the step responses of the systems


given in (1).
Matlab Commands:
%Item 3
%1st plot
figure;
step(Ga, Gb, Gc, Gd, 1);
legend('Ga', 'Gb', 'Gc', 'Gd')
title('Step Response: Unstable and Undamped');
grid on;
%2nd plot
figure;
step(Gd, Ge, Gf, Gg, 5);
legend('Gd', 'Ge', 'Gf', 'Gg')
title('Step Response: Stable');
grid on;

Matlab Output:
4. Using the ltieview command determine the peak time, percent
overshoot, settling time and rise time of
G(s)=100/(s2-10s+100) by right-clicking the mouse anywhere
in the plot and selecting the characteristic

Matlab Commands:
%Item 4
sys_e = tf(100, [1 10 100]);
ltiview('step', sys_e)

Matlab Output:

%OVERSHOOT PEAK TIME (SEC) RISE TIME (SEC) SETTING TIME (SEC)

16.3 0.359 0.164 0.808

5. Create a matlab m file secondordersys.m that will accept and plot


the pole-zero map and step response showing %OS, rise time,
settling time and peak time. Matlab m file:

Matlab Commands:
function secondordersys(wn, zeta)
num = wn^2;
den = [1, 2*zeta*wn, wn^2];
sys = tf(num, den);
%plot 1
subplot(2, 1, 1);
pzmap(sys);
title(['PZMap: \zeta = ', num2str(zeta)])
%plot 2
subplot(2, 1, 2);
step(sys);
title('Step Response')
[wn_out, z_out] = damp(sys);
S = stepinfo(sys);

fprintf('Zeta: %.2f\n', zeta);


fprintf('Wn: %.2f\n', wn);
fprintf('Percent OS: %.4f\n', [Link]);
fprintf('Peak Time: %.2f\n', [Link]);
fprintf('Rise Time: %.2f\n', [Link]);
fprintf('Settling Time: %.2f\n', [Link]);
end
clc
secondordersys(10, 0.9)
Matlab Output:
6. Test your m file using the following values for and ω and ς.

ωn ς %OS TPeak Trise(Sec) Tsettling(Sec)

10 0.1 72.9156 0.31 0.11 3.84

10 0.2 52.6542 0.32 0.12 1.96

10 0.3 37.1410 0.32 0.13 1.12

10 0.4 25.3741 0.35 0.15 0.84

10 0.5 16.2929 0.36 0.16 0.81

10 0.6 9.4773 0.39 0.19 0.59

10 0.7 4.5986 0.44 0.21 0.60

10 0.8 1.5165 0.52 0.25 0.38

10 0.9 0.1524 0.72 0.29 0.47

10 0.1 72.9156 0.31 0.11 3.84

1 0.1 72.9156 3.14 1.13 38.37

2 0.1 72.9156 1.57 0.56 19.19

3 0.1 72.9156 1.05 0.38 12.79

4 0.1 72.9156 0.79 0.28 9.59

5 0.1 72.9156 0.63 0.23 7.67

6 0.1 72.9156 0.52 0.19 6.40

7 0.1 72.9156 0.45 0.16 5.48

8 0.1 72.9156 0.39 0.14 4.80

9 0.1 72.9156 0.35 0.13 4.26

10 0.1 72.9156 0.31 0.11 3.84


7. Create a matlab m file 'underdampedsys.m' that will accept the
parameters σ and ωd , for a 2nd order underdamped system. The
program will output the pzmap and the step response. Test the m
file using

Damping Constant σ Damped Frequency ωd


-1 1

-1 2.5

-1 5

-1 7.5

-1 10

-2.5 1

-5 1

-7.5 1

-10 1

-2.5 2.5

-5 5

-7.5 7.5

-10 10
function underdampedsys(sigma, wd)
%poles = -sigma +/- j*wd
%characteristic equation: s^2 + 2*sigma*s + (sigma^2 + wd^2)
wn_squared = sigma^2 + wd^2;
den = [1 2*sigma wn_squared];
num = wn_squared;
sys = tf(num, den);
%plot
figure;
subplot(1, 2, 1);
pzmap(sys);
title('Pole-Zero Map');
subplot(1, 2, 2);
step(sys);
title('Step Response')
end
underdampedsys(-5, 1)

Matlab Output:

You might also like