# MATLAB Sovling Bernoulli's differential equation in matlab?

Tags:
1. Apr 3, 2018

### Eswin Paul T

I have a first order bernoullis differential equation. I need to solve this in matlab. Can anyone help me?

2. Apr 3, 2018

### Staff: Mentor

What is the context of the question? Is this for schoolwork?

What is your level of experience with MATLAB? What is the DE (and the initial conditions), and which numerical method do you have in mind for solving it?

3. Apr 3, 2018

### Eswin Paul T

I am working on lidars to retrieve extinction coefficient. I have to solve the lidar equation using Klett method which involves reducing the lidar eqn to a first order bernoullis equation.

4. Apr 19, 2018

### kreil

I can't provide specific help since you didn't provide the equation, so instead I'll show you some ways to solve one of the Bernoulli equations in the Wikipedia article on Bernoulli differential equation.

The differential equation is,
$$x \frac{dy}{dx} + y = x^2 y^2$$
Bernoulli equations have the standard form
$$y' + p(x) y = q(x) y^n$$
So the first equation in this standard form is
$$\frac{dy}{dx} + \frac{1}{x} y = x y^2$$

Initial Value Problem
If you want to calculate a numerical solution to the equation by starting from a known initial state and simulating forward to a predetermined end point, then you have an initial value problem. The main ODE solver in MATLAB is ode45, and it only takes a few lines in a script to solve this equation for some initial condition y0 over a period of time tspan (I picked some random values):

Code (Text):

y0 = 0.1;
tspan = [0.5 20];

[x,y] = ode45(@bernoulli1, tspan, y0);
plot(x,y)

function dydx = bernoulli1(x,y)
% This function codes the equations and
% is called at each time step by ode45 to