You are on page 1of 12

# 1.

clc;
clear all;
num=[1 0];
den=[1 -2 -6];
sys=tf(num,den,0.1)

SOLUTION-
sys =

-------------

z^2 - 2 z - 6

## Discrete-time transfer function.

2.

clc;
clear all;
n1=[1];
n2=[1 0];
n3=[-1 2];
n4=[3];
d=[1 1 0.3];
t1=tf(n1,d,0.2)
t2=tf(n2,d,0.2)
t3=tf(n3,d,0.2)
t4=tf(n4,d,0.2)
h=[t1 t2;t3 t4]
[z p k]=zpkdata(h)

SOLUTION-
t1 =
1
-------------
z^2 + z + 0.3

## Sample time: 0.2 seconds

Discrete-time transfer function.

t2 =
z
-------------
z^2 + z + 0.3

## Sample time: 0.2 seconds

Discrete-time transfer function.

t3 =
-z + 2
-------------
z^2 + z + 0.3

## Sample time: 0.2 seconds

Discrete-time transfer function.

t4 =
3
-------------
z^2 + z + 0.3

## Sample time: 0.2 seconds

Discrete-time transfer function.

h =
From input 1 to output...
1
1: -------------
z^2 + z + 0.3

-z + 2
2: -------------
z^2 + z + 0.3

z
1: -------------
z^2 + z + 0.3
3
2: -------------
z^2 + z + 0.3

## Sample time: 0.2 seconds

Discrete-time transfer function.

z =

[] [0]
[2] []

P11 =

## [-0.5+ 0.223606797749979i; -0.5- 0.223606797749979i]

P12=
[-0.5+ 0.223606797749979i; -0.5- 0.223606797749979i]
P21=
[-0.5+ 0.223606797749979i; -0.5- 0.223606797749979i]
P22=
[-0.5+ 0.223606797749979i; -0.5- 0.223606797749979i]

k =

1 1
-1 3

3.
clc;
clear all;
n1=[1];
n2=[1 0];
n3=[-1 2];
n4=[3];
d=[1 1 0.3];
t1=tf(n1,d,0.2)
t2=tf(n2,d,0.2)
t3=tf(n3,d,0.2)
t4=tf(n4,d,0.2)
h=[t1 t2;t3 t4]
[z p k]=zpkdata(h)
h12=h(1,2)
step(h12)
SOLUTION-
h12 =

z
-------------
z^2 + z + 0.3

## Sample time: 0.2 seconds

Discrete-time transfer function.

Step Response
1

0.9

0.8

0.7

0.6
Am plitude

0.5

0.4

0.3

0.2

0.1

0
0 0.5 1 1.5 2 2.5 3 3.5 4
Time (seconds)

4.
clc;
clear all;
a=[-2];
b=[3];
c=[1;-1];
d=0;
sys=ss(a,b,c,d,'inputdelay',0.5,'outputdelay',[0.7,0])
h=c2d(sys,0.5)
step(h)
grid on
SOLUTION-
sys =

a =
x1
x1 -2

b =
u1
x1 3

c =
x1
y1 1
y2 -1

d =
u1
y1 0
y2 0

## Input delays (seconds): 0.5

Output delays (seconds): 0.7 0

h =
a =
x1
x1 0.3679

b =
u1
x1 0.9482

c =
x1
y1 0.5488
y2 -1

d =
u1
y1 0.6768
y2 0

## Input delays (sampling periods): 1

Output delays (sampling periods): 2 0
Sample time: 0.5 seconds
Discrete-time state-space model.
Step Response
1.5

1
To: Out(1)

0.5

0
Amplitude

-0.5
To: Out(2)

-1

-1.5
0 1 2 3 4 5 6 7 8 9 10
Time (seconds)

5.
clc;
clear all;
n=[2];
d=[1 -0.95];
t=tf(n,d,0.1,'inputdelay',25)

SOLUTION
step(t)

t=

z^(-25) * --------

z - 0.95

## Discrete-time transfer function.

Step Response
40

35

30

25
Amplitude

20

15

10

0
0 2 4 6 8 10 12 14
Time (seconds)

6.
clc;
clear all;
n=[1 0.4];
d=[1 -0.7];
t1=tf(n,d,0.3)
t2=tf(n,d,0.1)
subplot(2,1,1);
step(t1)
title('ts=0.3')
grid on
subplot(2,1,2);
step(t2)
title('ts=0.1')
grid on

SOLUTION
t1 =

z + 0.4

-------

z - 0.7

t2 =

z + 0.4

-------

z - 0.7

## Discrete-time transfer function.

ts=0.3
5

4
Amplitude

1
0 1 2 3 4 5 6 7
Time (seconds)

ts=0.1
5

4
Amplitude

1
0 0.5 1 1.5 2 2.5
Time (seconds)
7.
clc;
clear all;
n=[1];
d=[1 1 0];
t=tf(n,d)
sys=feedback(t,1)
subplot(2,2,1);
step(sys)
title('continuous')
grid on
kp=dcgain(sys)
n1=[1 0];
d1=[1];
t1=tf(n1,d1);
h1=t1*sys;
kv=dcgain(h1)
n2=[1 0 0];
d2=[1];
t2=tf(n2,d2);
h2=t2*sys;
ka=dcgain(h2)
m=c2d(sys,1)
subplot(2,2,2);
step(m)
title(' Discrete,ts=1')
grid on
kp1=dcgain(m)
l1=[1 -1];
b1=[1];
x1=tf(l1,b1,1);
u1=x1*m;
kv1=dcgain(u1)
l2=[1 -2 1];
b2=[1];
x2=tf(l2,b2,1);
u2=x2*m;
ka1=dcgain(u2)
disp('Analog')
stepinfo(sys)
disp('Sampled')
stepinfo(m)
p1=d2c(m)
r=[1 1 1]
p2=tf(n,r,'inputdelay',0.5)
p3=c2d(p2,1)
subplot(2,2,3);
step(p2)
title('Analog with delay 0.5')
grid on
subplot(2,2,4);
step(p3)
title('discrete with delay')
grid on
SOLUTION
t =

1
-------
s^2 + s

sys =

1
-----------
s^2 + s + 1

## Continuous-time transfer function.

kp =

kv =

ka =

m =

0.3403 z + 0.2417
-----------------------
z^2 - 0.7859 z + 0.3679

## Sample time: 1 seconds

Discrete-time transfer function.

kp1 =

1.0000

kv1 =
0

ka1 =

Analog

ans =

RiseTime: 1.6390
SettlingTime: 8.0759
SettlingMin: 0.9315
SettlingMax: 1.1629
Overshoot: 16.2929
Undershoot: 0
Peak: 1.1629
PeakTime: 3.5920

Sampled

ans =

RiseTime: 2
SettlingTime: 9
SettlingMin: 0.9744
SettlingMax: 1.1531
Overshoot: 15.3123
Undershoot: 0
Peak: 1.1531
PeakTime: 4

p1 =

1
-----------
s^2 + s + 1

## Continuous-time transfer function.

r =

[1 1 1
p2 =
=
1
exp(-0.5*s) * -----------
s^2 + s + 1

p3 =

## 0.1044 z^2 + 0.424 z + 0.05355

z^(-1) * ------------------------------
z^2 - 0.7859 z + 0.3679

## Sample time: 1 seconds

Discrete-time transfer function.