|
1 | 1 | %========================================================================== |
2 | 2 | % |
3 | | -% odericcati Solves the Riccati differential equation for the |
| 3 | +% solve_riccati_ode Solves the Riccati differential equation for the |
4 | 4 | % finite-horizon linear quadratic regulator. |
5 | 5 | % |
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) |
8 | 8 | % |
9 | 9 | % Copyright © 2021 Tamas Kis |
10 | | -% Last Update: 2022-06-07 |
| 10 | +% Last Update: 2022-08-28 |
11 | 11 | % Website: https://tamaskis.github.io |
12 | 12 | % Contact: tamas.a.kis@outlook.com |
13 | 13 | % |
14 | 14 | % TECHNICAL DOCUMENTATION: |
15 | 15 | % https://tamaskis.github.io/documentation/Riccati_Differential_Equation.pdf |
16 | 16 | % |
17 | 17 | % 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) |
19 | 19 | % |
20 | 20 | %-------------------------------------------------------------------------- |
21 | 21 | % |
|
53 | 53 | % 4. (A-BR^(-1)S^T,Q-SR^(-1)S^T) detectable |
54 | 54 | % • if S = 0, this condition reduces to (A,Q^(1/2)) detectable |
55 | 55 | % |
56 | | -% ----- |
57 | | -% NOTE: |
58 | | -% ----- |
59 | | -% --> N+1 = length of time vector |
60 | | -% |
61 | 56 | %========================================================================== |
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) |
63 | 58 |
|
64 | 59 | % ---------------------- |
65 | 60 | % Determines dimensions. |
|
91 | 86 | dPdt = @(t,P) -(A.'*P+P*A-(P*B+S)/R*(B.'*P+S.')+Q); |
92 | 87 |
|
93 | 88 | % converts matrix-valued ODE to vector-valued ODE |
94 | | - dydt = odefun_mat2vec(dPdt); |
| 89 | + dydt = mat2vec_ode(dPdt); |
95 | 90 |
|
96 | 91 | % converts matrix initial condition to vector initial condition |
97 | | - yT = ivpIC_mat2vec(PT); |
| 92 | + yT = mat2vec_IC(PT); |
98 | 93 |
|
99 | 94 | % solves Riccati ODE |
100 | 95 | [t,y] = ode45(dydt,tspan,yT); |
101 | 96 |
|
102 | 97 | % transforms solution matrix for vector-valued ODE into solution array |
103 | 98 | % for matrix-valued ODE |
104 | | - P = ivpsol_vec2mat(y); |
| 99 | + P = vec2mat_sol(y); |
105 | 100 |
|
106 | 101 | % reorders t so that time is increasing |
107 | 102 | t = flipud(t); |
|
0 commit comments