I wrote the code below and it worked for several weeks without any problem. Suddenely it stoped working with following error:
"warning: lsode: passing function body as a string is obsolete; please use anonymous functions
warning: called from
heun at line 23 column 2
error: 'f' undefined near line 1 column 42
error: lsode: evaluation of user-supplied function failed
error: called from
__lsode_fcn__C__ at line 1 column 40
heun at line 23 column 2"
The code is:
function yn=euler(t0,y0,tend,f,n)
t0=input('Gib hier t0 ein:');
y0=input('Gib hier y0 ein:');
tend=input('Bis zu welchem Wert von t möchtest du y annährn?');
n=input('Gib hier die Anzahl der Schritte ein(n):');
fstrich=input('Wie lautet die Differentialgleichung?', 's');
f=inline('fstrich');
dt=(tend-t0)/n;
t(1)=t0;
y(1)=y0;
for i=1:n
t(i+1)=t(i)+dt;
y(i+1)=y(i)+f(t(i),y(i))*dt;
rotdim([flip(t) ; flip(y)])
scatter(t,y,'*')
hold on
f=inline('fstrich');
t=t0:0.001:tend;
y=lsode('f',y0,t);
plot(t,y)
Does anyone see a mistake or something I can change?
Apparently you updated octave.
Instead, make an anonymous function