EE422

Sol'n to HW#23

 

1. Recall the continuous-time, state variable model from HW#16: (Please, use Matlab liberally on this first problem!)

 

 

a) Is the continuous model stable, marginally stable, or unstable?

» a=[3/2 -1/2 0;1/2 5/2 1;1 1 2]

 

a =

 

1.5000 -0.5000 0

0.5000 2.5000 1.0000

1.0000 1.0000 2.0000

 

» b=[1/2;1/2;0]

 

b =

 

0.5000

0.5000

0

 

» c=[2 2 0]

 

c =

 

2 2 0

 

» eig(a)

 

ans =

 

2.0000

3.0000

1.0000

 

» %1a) The continuous time system is UNSTABLE because eigenvalues are in the RHP.

b) Discretize the model using with Ts=ln(2) sec. Remember, if A-1 exists then you can use the trick that

» T=log(2)

 

T =

 

0.6931

 

» Ahat=expm(a*T)

 

Ahat =

 

2.5000 -1.5000 -0.5000

2.5000 6.5000 3.5000

3.0000 3.0000 5.0000

 

» Bhat=inv(a)*[expm(a*T)-eye(3)]*b

 

Bhat =

 

0.4167

1.2500

0.6667

 

c) Is the discrete model stable, marginally stable, or unstable? Is it controllable (find )?

» eig(Ahat)

 

ans =

 

4.0000

8.0000

2.0000

 

» %1c) The discrete time system is UNSTABLE because eigenvalues are outside U.C.

» M=[Bhat Ahat*Bhat Ahat^2*Bhat]

 

M =

 

0.4167 -1.1667 -24.3333

1.2500 11.5000 101.0000

0.6667 8.3333 72.6667

 

» rank(M)

 

ans =

 

3

 

» %1c) The discrete system is completely controllable

» s_desired=[-2 -4 -5]

 

s_desired =

 

-2 -4 -5

 

d) Pick closed-loop eigenvalues in the S-plane of {-2 -4 -5} and map these values into the Z-plane.

 

» z_desired=exp(s_desired*T)

 

z_desired =

 

0.2500 0.0625 0.0312

 

e) Using these eigenvalues in the Z-plane, design a feedback regulator, Vin=-Kxk, such that the closed-loop discrete system has these eigenvalues (i.e., the eigenvalues of ) (If you are hazy, follow the procedures given in HW#16 to do this)

» %1d) First, find Apv and Bpv

» Bpv=[0;0;1]

 

Bpv =

 

0

0

1

 

» poly(Ahat)

 

ans =

 

1.0000 -14.0000 56.0000 -64.0000

 

» Apv=[0 1 0;0 0 1;-ans(4) -ans(3) -ans(2)]

 

Apv =

 

0 1.0000 0

0 0 1.0000

64.0000 -56.0000 14.0000

 

» %Now we can find Mpv and Tpv

» Mpv=[Bpv Apv*Bpv Apv^2*Bpv]

 

Mpv =

 

0 0 1.0000

0 1.0000 14.0000

1.0000 14.0000 140.0000

 

» Tpv=M*inv(Mpv)

 

Tpv =

 

15.3333 -7.0000 0.4167

10.0000 -6.0000 1.2500

-6.6667 -1.0000 0.6667

 

» %Check the value of Tpv by finding Apv and Bpv:

» inv(Tpv)*Ahat*Tpv

 

ans =

 

0.0000 1.0000 0.0000

0.0000 0.0000 1.0000

64.0000 -56.0000 14.0000

 

» %This is correct for Apv

» inv(Tpv)*Bhat

 

ans =

 

0.0000

0

1.0000

 

» %This is correct for Bpv

» %Next, find desired characteristic polynomial

» poly(z_desired)

 

ans =

 

1.0000 -0.3438 0.0254 -0.0005

 

» %Now find Kpv

» Kpv=[ans(4)+Apv(3,1) ans(3)+Apv(3,2) ans(2)+Apv(3,3)]

 

Kpv =

 

63.9995 -55.9746 13.6562

 

» %Check by finding the eigenvalues of Apv-Bpv*Kpv

» eig(Apv-Bpv*Kpv)

 

ans =

 

0.0313

0.0625

0.2500

 

» %They check!

» %As a last step, find w_k=-Kpv*inv(Tpv)x_k

» Kpv*inv(Tpv)

 

ans =

 

-0.4570 9.3099 3.3139

 

» %Check by finding the eigenvalues of Ahat-Bhat*K

» K=Kpv*inv(Tpv)

 

K =

 

-0.4570 9.3099 3.3139

 

 

f) How does your gain K compare to the analog gain K given in the solution to HW#16?

 

» %1f) The value of K in HW#16 was K = [-151.0000 185.0000 -73.0000]

» % This is not very close, but obviously works!

 

h) Please check your answer by calculating the eigenvalues . What is the settling time of the closed-loop discrete system.

 

» eig(Ahat-Bhat*K)

 

ans =

 

0.0313

0.0625

0.2500

 

» %They check, too!

 

2a)

h[kT] = 8(u[(k-1)T] - u[(k-4)T]), w[kT]=2(u[kT]-u[(k-2)T]):

 

Let's find a useful result before we solve this problem:

Plot

b)

Plot:

As you can see from the plots, the answers for parts a) and b) are the same!

c)

Find the transfer function, H(z), for both your h[k] form part a) and your h[k] from part b):

Part a):

Part b):

Are they the same?? Let's see:

Let's use long division on this result:

As we can see from the long division,

d)

let

which is the same answer we obtained for part b)!

 

e)

Graphical convolution: k = 0:

 

Note that y(0) =y(kT)=0, k < 0

 

k = 1

:

y(T)=16

k = 2

:

y(2T)=16+16=32

k = 3

:

 

y(3T)=16+16=32

k = 4

:

y(4T)=16

k = 5

:

y(5T)=y(kT)=0 for k>5

 

f)

w[k] = 2(u[(k-5)T]-u[(k-7)T]) + 8(u[kT]-u[(k-2)T]) = wold[k-5] + 4wold[k]