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
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

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



Loading...
Similar Threads for Octave differential equations Date
MATLAB Sovling Bernoulli's differential equation in matlab? Apr 3, 2018
MATLAB Octave integral computation help Apr 20, 2017
Octave debug info randomly displayed May 19, 2015
MATLAB How to solve complex 1st order ODEs in octave/Matlab Apr 30, 2014
I need help plotting some data using octave Feb 9, 2013