I can't say I've ever used lsode
before, but when I've had a variable in a function that I've wanted to change, I've had to declare it a global variable and then redefine the function. Something like
%doesn't work
f = @(x) a*x+2
for a= 0.1:0.1:20
f(1)
end
%does work
for a= 0.1:0.1:20
f = @(x) a*x+2 %your function here
%I usually end up using arrayfun() here in my applications, maybe lsode would work?
end
I'm no Octave expert, but this has worked for me, so maybe it'll work for you too.