[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Integration code
From: |
Markus Mützel |
Subject: |
Re: Integration code |
Date: |
Thu, 16 Apr 2020 15:27:46 +0200 |
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
Description: Text document