help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem solving ODE


From: Doug Stewart
Subject: Re: problem solving ODE
Date: Wed, 16 Nov 2011 22:49:20 -0500




On Wed, Nov 16, 2011 at 10:26 PM, Denise Estrada <address@hidden> wrote:
Hi, I'm new to Octave and I've been trying to learn by doing some  examples I found in the Octave-help manual.
The problem is that I get the same error all the time:

function xdot = f (x, t)

       xdot = zeros (3,1);

       xdot(1) = 77.27 * (x(2) - x(1)*x(2) + x(1) \
                 - 8.375e-06*x(1)^2);
       xdot(2) = (x(3) - x(1)*x(2) - x(2)) / 77.27;
       xdot(3) = 0.161*(x(1) - x(3));

     endfunction
 t = linspace (0, 500, 1000);

     y = lsode ("f", x0, t);

warning: function name `f' does not agree with function file name `/home/den

ise/Simoctave/otroejemplo2.m'

parse error near line 11 of file /home/denise/Simoctave/otroejemplo2.m

syntax error

>>> t = linspace (0, 500, 1000);

^

Thank's in advance

_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave



Hi

Tthis part of your program should be in a file by itself named  f.m


function xdot = f (x, t)

       xdot = zeros (3,1);

       xdot(1) = 77.27 * (x(2) - x(1)*x(2) + x(1) \
                 - 8.375e-06*x(1)^2);
       xdot(2) = (x(3) - x(1)*x(2) - x(2)) / 77.27;
       xdot(3) = 0.161*(x(1) - x(3));

     endfunction


then from the prompt in Octave you can trt:


 t = linspace (0, 500, 1000);

     y = lsode ("f", x0, t);



HTH

Doug

--
DAS

https://linuxcounter.net/user/206392.html

reply via email to

[Prev in Thread] Current Thread [Next in Thread]