solving differential riccati equation with a boundary condition

Ifunanya · Mar 11, 2022 · 2.1K views
Question
i would like to solve a riccati differential equation using matlab
Expert Answer
Profile picture of John Williams
John Williams PhD Expert
Answered Aug 24, 2026

Since the Riccati equation is a first-order ordinary differential equation, you can do this easily with any of the ODE solvers available in MATLAB such as "ode45".

The trick is to find the solution backwards in time.
 
As an example, let us consider the following example. Let the Riccati equation be given by
 
y'(t) = q0 + q1*y(t) + q2*y(t)^2,  
y(tf) = yf

where q0, q2 are non-vanishing constants (these may be nontrivial functions of t, the fact that they are chosen to be constant is just for simplicity). The second line is the boundary condition that at the end time tf, the value of the solution must be yf. I have chosen, in particular, tf = 2 and yf = 1 in the example code below.

function riccatiEquationRunner()

par = [1;2;1];  % q0, q1, and q2
yf = 1;
ti = 0; tf = 2;
opt = odeset('AbsTol',1.0e-07,'RelTol',1.0e-07);
[t,y] = ode45( @riccatiEquation, [tf,ti], yf ,opt, par);

% Visualize
plot(t,y)

end

function dydx = riccatiEquation(x,y,parameters)

q0 = parameters(1);
q1 = parameters(2);
q2 = parameters(3);

dydx = q0 + q1*y + q2*y*y;

end

 

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!