Second-Order System Example #2

MATLAB Code




%         ***** MATLAB Code Starts Here
%

%SECOND_ORDER_02_MAT

%

fig_size = [232 84 774 624];

zeta = 0.5; % values for basic system

wn = 4;

num0 = wn^2; den0 = [1 2*zeta*wn 0]; % basic transfer function

[ncl0,dcl0] = feedback(num0,den0,1,1,-1);

%

t = linspace(0,4,1001); % time vector

ys0 = step(ncl0,dcl0,t); % step response for basic system

%

figure(1),clf,plot(t,ys0),grid,xlabel('Time (s)'),...

ylabel('Amplitude'),title('Step Response: zeta = 0.5, wn = 4 r/s'),...

text(1.25,0.7,'P.O. = 16.3%, Ts = 2 s'),set(gcf,'Position',fig_size)

%

% Study the effect of adding an open-loop zero

% to the system

%

z = [0.2 0.5 1 2 5 10]; % values for additional zero

%

for i = 1:length(z)

numz(i,:) = (wn^2 / z(i)) * [1 z(i)];

[nclz(i,:),dclz(i,:)] = feedback(numz(i,:),den0,1,1,-1);

clpz(:,i) = roots(dclz(i,:));

ysz(:,i) = step(nclz(i,:),dclz(i,:),t); % step responses with zeros

end

%

figure(2),clf,plot(t,ysz),grid,xlabel('Time (s)'),...

ylabel('Amplitude'),title('Step Response with One Zero in Open-Loop System'),...

text(0.1,0.98,'z = 0.2'),text(1.2,1.07,'z = 10'),set(gcf,'Position',fig_size)

%

% Study the effect of adding an open-loop pole

% to the system

%

p = [1 2 5 10 20]; % values for additional pole

t = 5*t; % new time vector

%

for i = 1:length(p)

nump(i) = p(i) * num0;

denp(i,:) = conv(den0,[1 p(i)]);

[nclp(i,:),dclp(i,:)] = feedback(nump(i),denp(i,:),1,1,-1);

clpp(:,i) = roots(dclp(i,:));

ysp(:,i) = step(nclp(i,:),dclp(i,:),t); % step responses with extra pole

end

%

figure(3),clf,plot(t,ysp),grid,xlabel('Time (s)'),...

ylabel('Amplitude'),title('Step Response with Extra Pole in Open-Loop System'),...

text(2.6,1.7,'p = 1'),set(gcf,'Position',fig_size)

%

%
%         ***** MATLAB Code Stops Here

Click the icon to return to the Dr. Beale's home page