I am using ODE45 to integrate a system of differential equations and show their dynamics across 150ms. I am struggling with being precise about the time span of integration. More precisely, I have four vectors related to time:
dt = 0.25;
time = 0:dt:150;
T is the output of the ODE solver and it's correctly a 1x601 vector.
TimeInj, which is the time span of IInj, one of the time-dependent terms that I am interpolating.
TimeSyn, the time span of IPSC and EPSC, the other two time-dependent terms that I am interpolating
So, each vector has the same time span of 150ms, with one difference: the timestep is 0.5 for TimeInj, resulting in a 1x301 vector and 0.25 for TimeSyn, resulting in a 1x601 vector.
This is the part of my solver where I'm interpolating and integrating:
function dydt = myode(T,Vmnh,TimeInj,IInj,TimeSyn,Gsyn)
IInj = interp1(TimeInj,IInj,T);
IPSC = interp1(TimeSyn,IPSC,T);
EPSC = interp1(TimeSyn,EPSC,T);
dydt = [((1/Cm)*(IInj-(INa+IK+Il+IPSC+EPSC)));
However, as you can see from the image I attached, the timespan for Current IInj and Synaptic Conductances EPSC and IPSC is correctly 150, while the one for the first and four subplot is not correct and has lots of NaN values starting from a certain point. I think I'm doing something wrong with either the time steps or I'm not respecting some rules with the time spans. Thanks!