Skip to content

Commit b3f6108

Browse files
committed
updated for compatibility with new version of IVP solver toolbox
1 parent e1a7bef commit b3f6108

4 files changed

Lines changed: 18 additions & 26 deletions

File tree

EXAMPLES.mlx

-1.54 KB
Binary file not shown.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

5-
**NOTE:** This function requires the [ODE Solver Toolbox](https://www.mathworks.com/matlabcentral/fileexchange/103975-ode-solver-toolbox).
5+
**NOTE:** This function requires the [IVP Solver Toolbox](https://www.mathworks.com/matlabcentral/fileexchange/103975-ivp-solver-toolbox).
66

77

88
## Syntax

Riccati_Differential_Equation.pdf

842 Bytes
Binary file not shown.

odericcati.m

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,15 @@
77
% [t,P] = odericcati(A,B,Q,R,S,PT,tspan)
88
%
99
% Copyright © 2021 Tamas Kis
10-
% Last Update: 2021-12-23
10+
% Last Update: 2022-06-07
1111
% Website: https://tamaskis.github.io
1212
% Contact: tamas.a.kis@outlook.com
1313
%
1414
% TECHNICAL DOCUMENTATION:
1515
% https://tamaskis.github.io/documentation/Riccati_Differential_Equation.pdf
1616
%
17-
% REFERENCES:
18-
% [1] https://www.mathworks.com/help/control/ref/icare.html
19-
% [2] https://tamaskis.github.io/documentation/Fixed_Step_ODE_Solvers.pdf
20-
% [3] https://github.com/tamaskis/ODE_Solver_Toolbox-MATLAB
21-
% [4] Lavretsky and Wise, "Robust and Adaptive Control with Aerospace
22-
% Applications" (p. 35)
23-
% [5] https://en.wikipedia.org/wiki/Linear-quadratic_regulator
24-
%
25-
% This function requires the ODE Solver Toolbox:
26-
% https://www.mathworks.com/matlabcentral/fileexchange/103975-ode-solver-toolbox
17+
% DEPENDENCIES:
18+
% --> IVP Solver Toolbox (https://www.mathworks.com/matlabcentral/fileexchange/103975-ivp-solver-toolbox)
2719
%
2820
%--------------------------------------------------------------------------
2921
%
@@ -72,48 +64,48 @@
7264
% ----------------------
7365
% Determines dimensions.
7466
% ----------------------
75-
67+
7668
% state dimension
7769
n = size(A,1);
78-
70+
7971
% input dimension
8072
m = size(B,2);
81-
73+
8274
% ----------------------------------------------------
8375
% Sets unspecified parameters to their default values.
8476
% ----------------------------------------------------
85-
77+
8678
% defaults cross-coupling matrix to 0
8779
if isempty(S)
8880
S = zeros(n,m);
8981
end
90-
82+
9183
% ---------
9284
% Solution.
9385
% ---------
94-
86+
9587
% flips tspan so the Riccati ODE is solved backwards in time
9688
tspan = fliplr(tspan);
97-
89+
9890
% defines Riccati ODE has a matrix-valued ODE
9991
dPdt = @(t,P) -(A.'*P+P*A-(P*B+S)/R*(B.'*P+S.')+Q);
100-
92+
10193
% converts matrix-valued ODE to vector-valued ODE
10294
dydt = odefun_mat2vec(dPdt);
103-
95+
10496
% converts matrix initial condition to vector initial condition
105-
yT = odeIC_mat2vec(PT);
97+
yT = ivpIC_mat2vec(PT);
10698

10799
% solves Riccati ODE
108100
[t,y] = ode45(dydt,tspan,yT);
109-
101+
110102
% transforms solution matrix for vector-valued ODE into solution array
111103
% for matrix-valued ODE
112-
P = odesol_vec2mat(y);
113-
104+
P = ivpsol_vec2mat(y);
105+
114106
% reorders t so that time is increasing
115107
t = flipud(t);
116-
108+
117109
% reorders solution for P
118110
P_reordered = zeros(size(P));
119111
for k = 1:length(t)

0 commit comments

Comments
 (0)