Help with Riccati equation

2 views (last 30 days)
Mikle Frolov
Mikle Frolov on 29 May 2023
Commented: Mikle Frolov on 1 Jun 2023
% Define the Riccati equation and initial conditions
A = [0 1; -1 0]; Q = [1 0; 0 1]; R = 1; P0 = [1 0; 0 1];
% Determine the integral manifold
[V,D] = eig(Q);
M = V * sqrt(inv(D));
% Define the ODE function for numerical integration
f = @(t,P) -A' * P - P * A + P * B * inv(R) * B' * P + Q;
% Solve the ODE on the manifold
[t,P] = ode45(@(t,P) M \ f(t,M * P * M') * M', [0 10], M * P0 * M');
% Plot the solution trajectory on the manifold
plot(P(:,1,1), P(:,2,2));
xlabel('P_{11}');
ylabel('P_{22}');
title('Solution Trajectory on Manifold');
matlab complains about ode45 but I can’t figure out the reason for 2 days already((

Answers (1)

Alan Stevens
Alan Stevens on 29 May 2023
You haven't defined B (in the function definition)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!