Need help with discrete time SS controllability & phase portrait

6 views (last 30 days)
Woohoo PAKFA
Woohoo PAKFA on 9 Oct 2021
Commented: Paul on 12 Oct 2021
I'm very basic in MATLAB, I want to solve the above, I've read some documentation, theory and other Q/A's, but am unable to solve this. I'm attaching the code below till the point I understand and after that it gives an error.
A = [1 0.4;0 1];
B = [0.08;0.4];
% I've assumed y=x1
C = [1 0];
x0 = [1;1];
x50 = [-5;12];
% I tried using idss(A,B,C,0,x0,1) but gives some error, if I use idss(A,B,C,0,x0,x0,x50,1) it doesn't give error, but introduces some K & idk how to proceed then. I have taken time-step as 1, idk if I should alter that.
% How do I specify both initial (i.e. x(k=0)) & final intended position (i.e. x(k=50))?
sysss = ss(A,B,C,0,1)
% not sure if this is correct since 't or i' only goes to 50 not infinity.
% Also if I should use lyap or gram?
Wd = lyap (A, B*B')
u(i) = -(A^(n-1-i)*B)'*inv(Wd)*(A^(n)*x0-x50);
% OR
u(i) = -(B'*(A')^(n-1-i))*inv(Wd)*(A^(n)*x0-x50);
% both give error, and idk how else to solve/proceed
% Once I get the values of u(0) to u(49)-in matrix form I think according to the theory, then how to plot them, again idk
% the syntax for phase portrait (even if I find it, I cant solve the errors)

Accepted Answer

Paul on 9 Oct 2021
Edited: Paul on 9 Oct 2021
Do you have a source for the equations you're trying to implement to solve for u?
I thought that the controllability Grammian as the solution of the discrecte Lyapunov equation is the sum over n = 0 to inf, as discussed in
doc gram
But in this problem we only need the "portion" of the Grammian from n = 0 to 50. So the first thing is to find the corrrect equation that solves for u. Then we can figure out the Matlab code. Is this link helpful: General State Transfer and Reachabilty ?
Also, the lyap() function is for continuous systems. The dlyap() function is used for discrete systems. However, neither of these functions need be used for this problem, I don't believe.
Paul on 12 Oct 2021
2. Yes, that line basically says that each time through the loop assign as the new value of Wd the old value of Wd + that other stuff. It is implementing the summation in the middle of the slide that defines Wd.
3. Matlab arrays start with an index of 1. So we can't use the u(0) for the variable in the problem of u0. Instead, u(1) in the Matlab array is u0 in the problem. I thought that you basically wrote that equation for u(ii+1). All it is doing is filling in the values of u0, u1, u2, ... u49 into the Matlab array u using the equation in the middle of the slide, keeping in mind that u0 maps to u(1), u1 to u(2), etc. From the problem statement, you need to find u0 - 49, which are fifty elements of u. But x50 is the is the 51st element of the state vector (counting from 0), so we need to make sure that the Matlab array u has 51 elements so that lsim will compute 51 iterations of the state vector, x0 - x50. The 51st element of the Matlab array u isn't actually used for any computation, which is why it can stay zero.
4. The lsim comand using [] as the time input just means that "time vector" elements are just the discrete integers 0,1, ...50. Each row of y is an iteration of the state vector. y(1,1) and y(1,2) correspond to the first and second elements of the initial state vector (x0), and y(end,1) and y(end,2) are the elements of the final (or "end" ) state vector (x50). I added those single points on the plot with the markers (the x and the o) to show the initial and ending position on the state trajectory. Just adds a bit of clarity, IMO.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!