# Integration code Classic List Threaded 3 messages Open this post in threaded view
|

## Integration code

 Hi.I am relatively new to Octave and my problem is most likely rather trivial, so I apologise in advance.I made a code for integrating a function. I use the code https://octave.org/doc/v5.2.0/Simple-Examples.html#Integrating-Differential-Equations from here. function x dot  =f(x,t)   D  =1.1    ka =3;   z  =10   umax=0.08   km =3   I0 =1   xdot(1)= (-x(1).*(D)).+((umax.*((I0.*2.717^(-ka.*x(1)*z))./((I0.*(2.717^(-ka.*x(1)*z))).+km))).*x(1))endfunction>> x0=[1;2];>> t= linspace (0,50,100)';>> x= lsode ("f",x0,t);But error appears:warning: lsode: passing function body as a string is obsolete; please use anonymous functionserror: 'f' undefined near line 1 column 43error: lsode: evaluation of user-supplied function failederror: called from    __lsode_fcn__to__ at line 1 column 41Do you know what should I do for the anonymous function  ??? And how I define “f" ??? I tried to look the script on Octave, but couldn’t understand it. It would be nice if you show me some examples Best regards Tae hoon lee
 On Wed, Apr 15, 2020 at 9:57 AM 이태훈 <[hidden email]> wrote:Hi.I am relatively new to Octave and my problem is most likely rather trivial, so I apologise in advance.I made a code for integrating a function. I use the code https://octave.org/doc/v5.2.0/Simple-Examples.html#Integrating-Differential-Equations from here. function x dot  =f(x,t)this should befunction xdot= F(x,t)   D  =1.1    ka =3;   z  =10   umax=0.08   km =3   I0 =1   xdot(1)= (-x(1).*(D)).+((umax.*((I0.*2.717^(-ka.*x(1)*z))./((I0.*(2.717^(-ka.*x(1)*z))).+km))).*x(1))endfunction>> x0=[1;2];>> t= linspace (0,50,100)';>> x= lsode ("f",x0,t);But error appears:warning: lsode: passing function body as a string is obsolete; please use anonymous functionserror: 'f' undefined near line 1 column 43error: lsode: evaluation of user-supplied function failederror: called from    __lsode_fcn__to__ at line 1 column 41Do you know what should I do for the anonymous function  ??? And how I define “f" ??? I tried to look the script on Octave, but couldn’t understand it. It would be nice if you show me some examples Best regards Tae hoon lee  -- DAS In reply to this post by 이태훈 Am 15. April 2020 um 15:57 Uhr schrieb "이태훈": > Hi. > I am relatively new to Octave and my problem is most likely rather trivial, so I apologise in advance. > I made a code for integrating a function.  > I use the code https://octave.org/doc/v5.2.0/Simple-Examples.html#Integrating-Differential-Equations from here.  > > function x dot  =f(x,t) >    D  =1.1 >    ka =3; >    z  =10 >    umax=0.08 >    km =3 >    I0 =1 >    xdot(1)= (-x(1).*(D)).+((umax.*((I0.*2.717^(-ka.*x(1)*z))./((I0.*(2.717^(-ka.*x(1)*z))).+km))).*x(1)) > endfunction > >> x0=[1;2]; > >> t= linspace (0,50,100)'; > >> x= lsode ("f",x0,t); >   > But error appears: > > warning: lsode: passing function body as a string is obsolete; please use anonymous functions > error: 'f' undefined near line 1 column 43 > error: lsode: evaluation of user-supplied function failed > error: called from >     __lsode_fcn__to__ at line 1 column 41 >   > Do you know what should I do for the anonymous function  ???  > And how I define “f" ???  > I tried to look the script on Octave, but couldn’t understand it.  > It would be nice if you show me some examples  There seems to be something wrong with the function you pasted. But to get you started, let's try to focus on the example at the link you pasted: You could either type the code as shown in the example at Octave's command window. Or you could paste it to a script (see attachment) and run that by calling its name at the command window. To write your own (simple) function, create a file that contains only that function and has the same name as the function. I hope this helps. Feedback on how we could improve the manual is always welcome. Markus demo_lsode.m (308 bytes) Download Attachment