Skip to content

Commit 6b9c9c6

Browse files
committed
renamed function and updated to be compatible with newer version of IVP Solver Toolbox
1 parent b3f6108 commit 6b9c9c6

File tree

4 files changed

+14
-19
lines changed

4 files changed

+14
-19
lines changed

EXAMPLES.mlx

-1.21 KB
Binary file not shown.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `odericcati` [![View Solution of the Riccati Differential Equation (odericcati) on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/104030-solution-of-the-riccati-differential-equation-odericcati)
1+
# `solve_riccati_ode` [![View Solution of the Riccati Differential Equation (odericcati) on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/104030-solution-of-the-riccati-differential-equation-odericcati)
22

33
Solves the Riccati differential equation for the finite-horizon linear quadratic regulator.
44

@@ -7,15 +7,15 @@ Solves the Riccati differential equation for the finite-horizon linear quadratic
77

88
## Syntax
99

10-
`[t,P] = odericcati(A,B,Q,R,[],PT,tspan)`\
11-
`[t,P] = odericcati(A,B,Q,R,S,PT,tspan)`
10+
`[t,P] = solve_riccati_ode(A,B,Q,R,[],PT,tspan)`\
11+
`[t,P] = solve_riccati_ode(A,B,Q,R,S,PT,tspan)`
1212

1313

1414
## Description
1515

16-
`[t,P] = odericcati(A,B,Q,R,[],PT,tspan)` solves the Riccati differential equation <img src="https://latex.codecogs.com/svg.latex?\inline&space;\dot{\mathbf{P}}=-\left[\mathbf{A}^{T}\mathbf{P}+\mathbf{P}\mathbf{A}-(\mathbf{P}\mathbf{B}+\mathbf{S})\mathbf{R}^{-1}(\mathbf{B}^{T}\mathbf{P}+\mathbf{S}^{T})+\mathbf{Q}\right]" title="" /> for <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{P}(t)\in\mathbb{R}^{{n}\times{n}}" title="" />, given the state matrix <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{A}\in\mathbb{R}^{{n}\times{n}}" title="" />, input matrix <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{B}\in\mathbb{R}^{{n}\times{m}}" title="" />, state weighting matrix <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{Q}\in\mathbb{R}^{{n}\times{n}}" title="" />, input weighting matrix <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{R}\in\mathbb{R}^{{m}\times{m}}" title="" />, terminal condition <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{P}_{T}\in\mathbb{R}^{{n}\times{n}}" title="" />, and the time span `tspan` over which to solve. `tspan` can be specified either as the 1×2 double `[t0,T]` where <img src="https://latex.codecogs.com/svg.latex?\inline&space;t=t_{0}" title="" /> is the initial time and <img src="https://latex.codecogs.com/svg.latex?\inline&space;t=T" title="" /> is the final time, or as a 1×(N+1) vector of times `[t0,t1,...,tNminus1,T]` at which to return the solution for <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{P}(t)" title="" />. It is assumed that the cross-coupling weighting matrix is <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{S}=\mathbf{0}_{{n}\times{m}}" title="" />.
16+
`[t,P] = solve_riccati_ode(A,B,Q,R,[],PT,tspan)` solves the Riccati differential equation <img src="https://latex.codecogs.com/svg.latex?\inline&space;\dot{\mathbf{P}}=-\left[\mathbf{A}^{T}\mathbf{P}+\mathbf{P}\mathbf{A}-(\mathbf{P}\mathbf{B}+\mathbf{S})\mathbf{R}^{-1}(\mathbf{B}^{T}\mathbf{P}+\mathbf{S}^{T})+\mathbf{Q}\right]" title="" /> for <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{P}(t)\in\mathbb{R}^{{n}\times{n}}" title="" />, given the state matrix <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{A}\in\mathbb{R}^{{n}\times{n}}" title="" />, input matrix <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{B}\in\mathbb{R}^{{n}\times{m}}" title="" />, state weighting matrix <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{Q}\in\mathbb{R}^{{n}\times{n}}" title="" />, input weighting matrix <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{R}\in\mathbb{R}^{{m}\times{m}}" title="" />, terminal condition <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{P}_{T}\in\mathbb{R}^{{n}\times{n}}" title="" />, and the time span `tspan` over which to solve. `tspan` can be specified either as the 1×2 double `[t0,T]` where <img src="https://latex.codecogs.com/svg.latex?\inline&space;t=t_{0}" title="" /> is the initial time and <img src="https://latex.codecogs.com/svg.latex?\inline&space;t=T" title="" /> is the final time, or as a 1×(N+1) vector of times `[t0,t1,...,tNminus1,T]` at which to return the solution for <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{P}(t)" title="" />. It is assumed that the cross-coupling weighting matrix is <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{S}=\mathbf{0}_{{n}\times{m}}" title="" />.
1717

18-
`[t,P] = odericcati(A,B,Q,R,S,PT,tspan)` does the same as the syntax above, but this time the cross-coupling weighting matrix <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{S}\in\mathbb{R}^{{n}\times{m}}" title="" /> *is* specified.
18+
`[t,P] = solve_riccati_ode(A,B,Q,R,S,PT,tspan)` does the same as the syntax above, but this time the cross-coupling weighting matrix <img src="https://latex.codecogs.com/svg.latex?\inline&space;\mathbf{S}\in\mathbb{R}^{{n}\times{m}}" title="" /> *is* specified.
1919

2020

2121
## Time Vector and Solution Array

Riccati_Differential_Equation.pdf

-42 Bytes
Binary file not shown.

odericcati.m renamed to solve_riccati_ode.m

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
%==========================================================================
22
%
3-
% odericcati Solves the Riccati differential equation for the
3+
% solve_riccati_ode Solves the Riccati differential equation for the
44
% finite-horizon linear quadratic regulator.
55
%
6-
% [t,P] = odericcati(A,B,Q,R,[],PT,tspan)
7-
% [t,P] = odericcati(A,B,Q,R,S,PT,tspan)
6+
% [t,P] = solve_riccati_ode(A,B,Q,R,[],PT,tspan)
7+
% [t,P] = solve_riccati_ode(A,B,Q,R,S,PT,tspan)
88
%
99
% Copyright © 2021 Tamas Kis
10-
% Last Update: 2022-06-07
10+
% Last Update: 2022-08-28
1111
% Website: https://tamaskis.github.io
1212
1313
%
1414
% TECHNICAL DOCUMENTATION:
1515
% https://tamaskis.github.io/documentation/Riccati_Differential_Equation.pdf
1616
%
1717
% DEPENDENCIES:
18-
% --> IVP Solver Toolbox (https://www.mathworks.com/matlabcentral/fileexchange/103975-ivp-solver-toolbox)
18+
% IVP Solver Toolbox (https://www.mathworks.com/matlabcentral/fileexchange/103975-ivp-solver-toolbox)
1919
%
2020
%--------------------------------------------------------------------------
2121
%
@@ -53,13 +53,8 @@
5353
% 4. (A-BR^(-1)S^T,Q-SR^(-1)S^T) detectable
5454
% • if S = 0, this condition reduces to (A,Q^(1/2)) detectable
5555
%
56-
% -----
57-
% NOTE:
58-
% -----
59-
% --> N+1 = length of time vector
60-
%
6156
%==========================================================================
62-
function [t,P] = odericcati(A,B,Q,R,S,PT,tspan)
57+
function [t,P] = solve_riccati_ode(A,B,Q,R,S,PT,tspan)
6358

6459
% ----------------------
6560
% Determines dimensions.
@@ -91,17 +86,17 @@
9186
dPdt = @(t,P) -(A.'*P+P*A-(P*B+S)/R*(B.'*P+S.')+Q);
9287

9388
% converts matrix-valued ODE to vector-valued ODE
94-
dydt = odefun_mat2vec(dPdt);
89+
dydt = mat2vec_ode(dPdt);
9590

9691
% converts matrix initial condition to vector initial condition
97-
yT = ivpIC_mat2vec(PT);
92+
yT = mat2vec_IC(PT);
9893

9994
% solves Riccati ODE
10095
[t,y] = ode45(dydt,tspan,yT);
10196

10297
% transforms solution matrix for vector-valued ODE into solution array
10398
% for matrix-valued ODE
104-
P = ivpsol_vec2mat(y);
99+
P = vec2mat_sol(y);
105100

106101
% reorders t so that time is increasing
107102
t = flipud(t);

0 commit comments

Comments
 (0)