You are on page 1of 15

Discrete-Time Systems

Problem 1................................................................................................................ 1
Part (a).................................................................................................................... 1
Part (b).................................................................................................................... 3
Part (c)..................................................................................................................... 4
Part (d).................................................................................................................... 5
Problem 2................................................................................................................ 6
Part (a).................................................................................................................... 6
Part (b).................................................................................................................... 9
Part (c)..................................................................................................................... 9
Part (d).................................................................................................................... 9
Part (e).................................................................................................................. 10
Part (f)................................................................................................................... 12
Problem 3.............................................................................................................. 14

Problem 1
Part (a)
clear all;
az = [0 1];
bz = [1 -0.8 0.81];
K = 0.722;
Ts = 0.01;
% Defining P(z):
P = K * tf(az, bz, Ts);
% Defining C(z):
C = 1;
% Defining transfer function, H(z):
H = C*P
% Bode plot:
figure(1);
bode(H);
grid on;

title('Bode Plot for H(z)=C(z)P(z) with C(z)=1');


% Stability from Gain Margin:
[Gm Pm Wgm Wpm] = margin(H);
GmdB = 20*log10(Gm);
figure(2);
margin(H);
grid on;
title('Stability determination with Bode plot for H(z)=C(z)P(z), C(z)=1');

H=
0.722
-----------------z^2 - 0.8 z + 0.81
Sample time: 0.01 seconds
Discrete-time transfer function.
Warning: The closed-loop system is
unstable.

Part (b)
clear all;
az = [0 1];
bz = [1 -0.8 0.81];
K = 0.722;
Ts = 0.01;
% Defining P(z):
P = K * tf(az, bz, Ts);

% Defining C(z) for which Gain Margin is 6dB:


C = -7.2128;
% Defining transfer function, H(z):
H = C*P
% Confirmation of Gain Margin:
[Gm Pm Wgm Wpm] = margin(H);
GmdB = 20*log10(Gm)

H=
-5.208
-----------------z^2 - 0.8 z + 0.81
Sample time: 0.01 seconds
Discrete-time transfer function.
Warning: The closed-loop system is
unstable.
GmdB =
-6.0000

Part (c)
% Bode plot for C(z)P(z) with C(z)=-7.2128

clear all;
az = [0 1];
bz = [1 -0.8 0.81];
K = 0.722;
Ts = 0.01;
% Defining P(z):
P = K * tf(az, bz, Ts);
% Defining C(z):
C = 1.13;
% Defining transfer function, H(z):
H = C*P
% Bode plot:
figure(3);
bode(H);
grid on;
title('Bode Plot for H(z)=C(z)P(z) with C(z)=-7.2128');
% Gain Margin and Phase margin:
[Gm Pm Wgm Wpm] = margin(H);
% Gain margin
GmdB = 20*log10(Gm)
% Phase margin
Pm

H=
0.8159
-----------------z^2 - 0.8 z + 0.81
Sample time: 0.01 seconds
Discrete-time transfer function.
Warning: The closed-loop system is
unstable.
GmdB =

-12.6568

Pm =
-76.3273

Part (d)
clear all;
az = [0 1];
bz = [1 -0.8 -4.4];
K = -5.2076;
Ts = 0.01;
% Defining transfer function, H(z)=P(z)/[1+P(z)C(z)]:
H = K * tf(az, bz, Ts);
% Step response
figure(4);

step(H);

Problem 2
Part (a)
clear all;
az = [0 1];
bz = [1 -1.9545 0.97023];
K = 0.1057;
Ts = 0.01;
% Defining P(z):
P = K * tf(az, bz, Ts);
% Defining C(z):
C = 1;
% Defining transfer function, H(z):

H = C*P
% Bode plot:
figure(5);
bode(H);
grid on;
title('Bode Plot for H(z)=C(z)P(z) with C(z)=1');
% Nyquist plot:
figure(6);
nyquist(H);
title('Nyquist plot for H(z) with C(z)=1');
grid on;
% Phase corresponding to 0 dB angular frequency:
[Gm Pm Wgm Wpm] = margin(H);
Pm
% Thus, the phase is: -194.6 deg
w0dB = -194.6;

H=
0.1057
---------------------z^2 - 1.954 z + 0.9702
Sample time: 0.01 seconds
Discrete-time transfer function.
Warning: The closed-loop system is
unstable.
Pm =
-14.6034

Part (b)
% From the previous calculation of phase angle, the angle needs to be added
% is: 220-194.6 = 25.4 deg
phi_c = 25.4

phi_c =
25.4000

Part (c)
phi_m = phi_c;
wm = w0dB*180/pi;
a = (cosd(phi_m)-sind(wm))/(cosd(phi_m-wm));
b = (cosd(phi_m)-sind(wm))/(cosd(phi_m+wm));
Klead = sqrt((1-2*a*cosd(wm)+a^2)/(1-2*b*cosd(wm)+b^2));
% Compensator transfer function C(z):
C = Klead*tf([1 -b],[1 -a],Ts)

C=
1.464 z - 1.307
--------------z - 0.7517
Sample time: 0.01 seconds
Discrete-time transfer function.

Part (d)
% Bode plot of C(z)
figure(7);
bode(C);
grid on;
title('Bode plot for compensated C(z)');
hold on;
margin(C);
% From the bode plot and the superimposed margin plot, it is evident that
% the compensator is working according to the criterion.

Part (e)
H = C*P;
% Bode plot:
figure(8);
bode(H);
grid on;
title('Bode plot for C(z)P(z) with compensator');
% Nyquist plot:
figure(9);
nyquist(H);
grid on;
title('Nyquist plot for C(z)P(z)');
% Phase and Gain margins:
[Gm Pm wm w0] = margin(H);
Gm
Pm

Gm =
1.0410

Pm =
0.8661

Part (f)
% Step response of the closed loop system after compensation:
HF = H/(1+H)
figure(10);
step(HF);
title('Step response of closed loop system with cmopensation');

HF =
0.1547 z^4 - 0.5569 z^3 + 0.7513 z^2 - 0.4499 z + 0.1008
---------------------------------------------------------------------z^6 - 5.412 z^5 + 12.36 z^4 - 15.22 z^3 + 10.65 z^2 - 4.008 z + 0.6327
Sample time: 0.01 seconds
Discrete-time transfer function.

Problem 3

Published with MATLAB R2012b

You might also like