%% Anti-Stabilizing Solution of Discrete-Time Algebraic Riccati Equation
% For this example, solve the discrete-time algebraic Riccati equation considering the following set of matrices:
% A=
%   \left[ {\begin{array}{cc}
%    -0.9 & -3\\
%    0.7 & 0.1 \\
%   \end{array} } \right]\;\;\;\;\;\;\;\;\;B=
%   \left[ {\begin{array}{c}
%    1\\
%    1\\
%   \end{array} } \right]\;\;\;\;\;\;\;\;\;Q=
%   \left[ {\begin{array}{cc}
%    1 & 0\\
%    0 & 3\\
%   \end{array} } \right]\;\;\;\;\;\;\;\;\;R = 0.1.
% Find the anti-stabilizing solution using the 'anti' option to solve for the above matrices with default values for S and E.

A = [-0.9,-0.3;0.7,0.1];
B = [1;1];
Q = [1,0;0,3];
R = 0.1;
[X,K,L] = idare(A,B,Q,R,[],[],'anti')

% Here, X is the unique anti-stabilizing solution, K contains the state-feedback gain, and L contains the closed-loop eigenvalues.
% Copyright 2018 The MathWorks, Inc.