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

Octave differential equations

  1. May 6, 2010 #1
    Hi, I've just started using Octave and I'd like to use it to solve and plot a system of differential equations, but I keep getting the same error which I don't understand. What have I done wrong in my code?

    Outline:
    Initial conditions
    x1 = 1
    x2 = 1.27 x 10^-6
    x3 = 0

    t = 0 - 140 days

    Equations
    dx1 = -0.5*x(1)*x(2)
    dx2 = 0.5*x(1)*x(2) - 0.25*x(3)
    dx3 = 0.25*x(2)

    Code:
    %function
    function xdot = m (x, t)
    xdot = zeros (3,1);
    xdot(1) = -0.5*x(1)*x(2);
    xdot(2) = 0.5*x(1)*x(2) - 0.25*x(3);
    xdot(3) = 0.25*x(2);
    endfunction

    %initial conditions
    x0 = [1;1.27e-06;0];
    t = linspace (0,140);

    %solve
    y = lsode ("m",x0,t)

    %plot
    plot (y,t)


    the error I get says
    lsode: repeated convergence failures

    Thanks!!
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Octave differential equations
  1. Octave/ Matlab (Replies: 2)

  2. Help with Octave (Replies: 3)

  3. Octave on Fedora (Replies: 2)

  4. Bug in Octave? (Replies: 1)

Loading...