Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB Sovling Bernoulli's differential equation in matlab?

Tags:
  1. Apr 3, 2018 #1
    I have a first order bernoullis differential equation. I need to solve this in matlab. Can anyone help me?
     
  2. jcsd
  3. Apr 3, 2018 #2

    berkeman

    User Avatar

    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?
     
  4. Apr 3, 2018 #3
    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.
     
  5. Apr 19, 2018 #4

    kreil

    User Avatar
    Gold Member

    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,
    [tex]x \frac{dy}{dx} + y = x^2 y^2[/tex]
    Bernoulli equations have the standard form
    [tex]y' + p(x) y = q(x) y^n[/tex]
    So the first equation in this standard form is
    [tex]\frac{dy}{dx} + \frac{1}{x} y = x y^2[/tex]

    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
    % advance the integration.
    dydx = x*y^2 - y*(1/x);
    end
    bernoulli1.png

    Symbolic Solution
    Instead of simulating the system, you can express it as a linear differential equation and solve it using known techniques (see here). This doesn't really require MATLAB, but if the expressions are complicated you can use Symbolic Math Toolbox to perform some of the integrations.

    Hopefully this general information is helpful. If you post more info on the equation you need to solve then maybe we can see about which technique is best.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?