aa
192 Chapter 5 / Transient and Steady-State Response Analyses
MATLAB Program 5–6
% ------- Two-dimensional plot and three-dimensional plot of unit-step
% response curves for the standard second-order system with wn = 1
% and zeta = 0, 0.2, 0.4, 0.6, 0.8, and 1. -------
t = 0:0.2:10;
zeta = [0 0.2 0.4 0.6 0.8 1];
for n = 1:6;
num = [1];
den = [1 2*zeta(n) 1];
[y(1:51,n),x,t] = step(num,den,t);
end
% To plot a two-dimensional diagram, enter the command plot(t,y).
plot(t,y)
grid
title('Plot of Unit-Step Response Curves with \omega_n = 1 and \zeta = 0, 0.2, 0.4, 0.6, 0.8, 1')
xlabel('t (sec)')
ylabel('Response')
text(4.1,1.86,'\zeta = 0')
text(3.5,1.5,'0.2')
text(3 .5,1.24,'0.4')
text(3.5,1.08,'0.6')
text(3.5,0.95,'0.8')
text(3.5,0.86,'1.0')
% To plot a three-dimensional diagram, enter the command mesh(t,zeta,y').
mesh(t,zeta,y')
title('Three-Dimensional Plot of Unit-Step Response Curves')
xlabel('t Sec')
ylabel('\zeta')
zlabel('Response')
An illustrative MATLAB Program for plotting a two-dimensional diagram and a three-
dimensional diagram of unit-step response curves of this second-order system is given in MATLAB
Program 5–6. The resulting plots are shown in Figures 5–22(a) and (b), respectively. Notice that
we used the command mesh(t,zeta,y')to plot the three-dimensional plot. We may use a command
mesh(y')to get the same result. [Note that command mesh(t,zeta,y)ormesh(y)will produce a
three-dimensional plot the same as Figure 5–22(b), except that xaxis and yaxis are interchanged.
See Problem A–5–15.]
When we want to solve a problem using MATLAB and if the solution process involves many
repetitive computations, various approaches may be conceived to simplify the MATLAB pro-
gram. A frequently used approach to simplify the computation is to use “for loops.” MATLAB Pro-
gram 5–6 uses such a “for loop.” In this book many MATLAB programs using “for loops” are
presented for solving a variety of problems. Readers are advised to study all those problems care-
fully to familiarize themselves with the approach.
Openmirrors.com