Changing input variable ode23
1 view (last 30 days)
Show older comments
Dear all,
I'm simulating a QIF-model for spiking neurons with a discrete resetting rule.
The code is added below.
close all
clc
%Firing rate equations for 2 neural masses with only electrical coupling
%& chemical coupling. N=10000
I_1= 0;
I_2= 0.5*pi;
params.tau= 10;
params.g= 2.2;
params.delta= 100;
params.J.GPe= 1.4 ;
params.J.STN= 1.4;
N= 10000;
V_1= -65;
R_1= 0;
V_2= -65;
R_2= 0;
I= [I_1;I_2];
y0=[V_1,V_2,R_1,R_2];
options = odeset('Events',@QIF_reset)
tstart=0
tfinal= 20000
tout=tstart
yout = y0;
teout = [];
yeout = [];
ieout = [];
for i = 1:13
% Solve until the first terminal event.
[t,y,te,ye,ie] = ode23(@(t,y)QIF(t,y,I,params,N),[tstart tfinal],y0,options);
if ~ishold
hold on
end
% Accumulate output. This could be passed out as output arguments.
nt = length(t);
tout = [tout; t(2:nt)];
yout = [yout; y(2:nt,:)];
teout = [teout; te]; % Events at tstart are never reported.
yeout = [yeout; ye];
ieout = [ieout; ie];
[row,col] = find(ye>99);
% Set the new initial conditions, with .9 attenuation.
y0(1) = ye(1);
y0(2) = ye(2);
y0(3) = ye(3);
y0(4) = ye(4);
y0(col)= -65;
y0(col+2)= 0;
% A good guess of a valid first timestep is the length of the last valid
% timestep, so use it for faster computation. 'refine' is 4 by default.
tstart = t(nt);
end
figure(1);
plot(tout,yout(:,1),'b',tout,yout(:,3),'k')
xlabel 'Time in ms'
ylabel 'Mean membrane potential'
title 'Mean membrane potential STN'
hold off
figure(2)
plot(tout,yout(:,2),'b',tout,yout(:,4),'k')
xlabel 'Time in ms'
ylabel 'Mean membrane potential'
title 'Mean membrane potential GPe'
hold off
The problem is that I would love to evaluate this model with varying Input.
Is that possible and if so how should the for loop look like?
3 Comments
Answers (0)
See Also
Categories
Find more on Neural Simulation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!