|
Hi Torsten,
Thanks for your reply. Unfortunately I think I do need the events function. I'll try and explain.
Basically I'm modelling multiple voltage pulses so you have these ODEs which are running and then every 10ms, a new stimulus comes and resets everything back again. Now because the whole thing depends on varying ion flow which changes over time (modelled in the ODEs), you won't see exactly the same behaviour each time you run it.
I need the integration to stop at 10ms then re-start from that exact point with the initial conditions reset. See this picture for an example of what I want !
http://capocaccia.ethz.ch/capo/attachment/wiki/2010/spinn10/LIF%20Model%20-%20Input%20Neuron%20Membrane%20Potential%20%28SpiNNaker%29.png
When I just run it in a loop, the different spikes aren't connected.
Thanks
David
Torsten <Torsten.Hennig@umsicht.fraunhofer.de> wrote in message <95365902-308e-4364-b7ee-8ac599409d49@gi10g2000vbb.googlegroups.com>...
> On 23 Feb., 20:05, "David Cox" <dcwrite...@googlemail.com> wrote:
> > Hi,
> >
> > I have a set of ODEs modelling neuronal spiking in the brain for a period of 200ms. I'm solving this using ode45 and I now want to alter it so that the initial conditions reset every 10ms.
> >
> > I realise I need to do this using the events option (I've been looking at the BALLODE m file as an example).
> >
> > However I'm not sure what I need to set 'value' as in my 'events' function because my threshold is for time rather than the output y ?
> >
> > Below is my code....Many thanks for any help anyone can give me !!!
> >
> > t = 0:200;
> > y0 = [60;0];
> > refine = 4;
> > options = odeset('Events',@events,'OutputFcn',@odeplot,'OutputSel',1,...
> > 'Refine',refine);
> > tout = 0;
> > yout = y0.';
> > teout = [];
> > yeout = [];
> > ieout = [];
> > for i = 1:10
> > % Solve until the first terminal event.
> > [t,y,te,ye,ie] = ode45(@neuron,t,y0,options);
> > if ~ishold
> > hold on
> > end
> > % Accumulate output. .
> > nt = length(t);
> > tout = [tout; t(2:nt)];
> > yout = [yout; y(2:nt,:)];
> > teout = [teout; te];
> > yeout = [yeout; ye];
> > ieout = [ieout; ie];
> >
> > ud = get(gcf,'UserData');
> > if ud.stop
> > break;
> > end
> >
> > % Set the new initial conditions
> > y0(1) = 60;
> > y0(2) = 0;
> > tstart = t(nt);
> > end
> > -------------------------------------------------------------------
> > function [value,isterminal,direction] = events(t,y)
> > % Stop integration every 10s.
> > value = ??????;
> > isterminal = 1; % stop the integration
> > direction = 0;
> >
> > end
>
> I don't understand. Do your ODEs explicity depend on time ?
> Otherwise, by resetting the initial conditions to the starting
> conditions,
> you'll get the same result over and over again.
>
> Anyhow: As far as I can see, there is no need to use the events
> option.
> Just call ODE45 in a loop in which you set the start time to the old
> end time
> and the new end time to the old end time + 10 ms:
>
> tfinal = 200;
> deltat = 10;
> nend = 20;
>
> For i = 1:nend
> [t,y] = ode45(@neuron,[(i-1)*deltat i*deltat],y0,options);
> ...
> [Store solution at time i*deltat and reset initial conditions]
> ...
> end
>
> Best wishes
> Torsten.
|