The m-file "dpre" solves the discrete-time periodic optimal control problem by a cyclic QZ method. It is not the fastest method available, but works quite well. The m-file "dpre" computes the unique stabilizing solution X{k} of the discrete-time periodic Riccati equation and also returns the gain matrix K{k} in the state-feedback u{k} = -K{k}x{k}, where k = 1:P.
Ivo Houtzager (2021). DPRE (https://www.mathworks.com/matlabcentral/fileexchange/21379-dpre), MATLAB Central File Exchange. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
Thank you very much after some corrections I got the right results. I think I was wrong about the size of the matrix L.
I don't fully understand your response about an L matrix of the size (11,11,36), probably you mean L matrix (4,11,36) for periodic state observer design. From your matrix sizes, I think you have periodic discrete state-space model of 4 states, 3 inputs, 11 outputs and period of 36. I tested the function with random generated discrete state-space models of this size and it runs without any problems for both periodic state feedback design (resulting in K matrix (3,4,36)) and periodic state observer design (resulting in L matrix (4,11,36)), see code below.
sys = drss(4,11,3,36);
for i=1:36
A(:,:,i) = sys.a(:,:,i);
B(:,:,i) = sys.b(:,:,i);
Q(:,:,i) = sys.c(:,:,i)'*sys.c(:,:,i);
end
[X,K] = dpre(A,B,Q); % periodic state feedback
for i=1:36
At(:,:,i) = sys.a(:,:,i)';
Bt(:,:,i) = sys.c(:,:,i)';
R(:,:,i) = sys.b(:,:,i)*sys.b(:,:,i)';
end
[X,Lt] = dpre(At,Bt,R); % periodic state observer
for i=1:36
L(:,:,i) = Lt(:,:,i)';
end
I checked precisely the matrices of these lines. Normally I should get an L matrix (11,11,36). My matrix Q is (4,4,36). I use the default values for the matrices E and S being E = I and S = 0.
What are the size of your Q, E and S matrices? Based on the error description it seems related to these matrices and not A and B.
Dear Dr Houtzager,
Your code helps me a lot in my research. Thanks for sharing this algorithm. However I have an error in when I read your function with my data. The error is as follows for the matrix L: "Dimensions of matrices being concatenated are not consistent. -Q (:,:, i) E (:,:, i) -S (:,:, i);"
I checked long and wide for the concatenation of the matrix. The sizes of the matrix are as follows :
A (4,4,36)
B (4,3,36)
Have you already encountered this kind of problem?
Thank you in advance for your answer.