File Exchange

image thumbnail

Discrete-time Periodic Riccati Equation (DPRE)

version (146 KB) by Ivo Houtzager
Discrete-time periodic Riccati equation solver for periodic LQ state-feedback design

1 Download

Updated 20 Apr 2021

From GitHub

View Version History

View license on GitHub

These functions solve the Discrete-time Periodic Riccati Equation (DPRE) for periodic LQ state-feedback design. The functions compute 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.

The m-file "dpre" solves the discrete-time periodic optimal control problem by a cyclic QZ or a Newton backward iteration method. These are not the fastest methods available, but work quite well.

The mex-file "dprex" solves the discrete-time periodic optimal control problem by a periodic QR (using functions from matlab's internal slicot library) or a complex periodic QC method (using converted fortran to c code from the pqzschur library). The mex-file implementation is much faster, but requires compilation of the mex file which can be done by running make_dprex.m.

Cite As

Ivo Houtzager (2021). Discrete-time Periodic Riccati Equation (DPRE) (, GitHub. Retrieved .

Comments and Ratings (5)


Thank you very much after some corrections I got the right results. I think I was wrong about the size of the matrix L.

Ivo Houtzager

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);
[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)';
[X,Lt] = dpre(At,Bt,R); % periodic state observer
for i=1:36
L(:,:,i) = Lt(:,:,i)';


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.

Ivo Houtzager

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.

MATLAB Release Compatibility
Created with R2020b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!