Page 1 of 1

How to save the time at each time step

Posted: Tue May 20, 2014 2:12 pm
by breakwave922
For some reason, I need to save the time history with specific time step. I use rect.record(&t,tstep), tstep=4 to save. But then all the time values I got is zero.
Any help is appreciated.

Re: How to save the time at each time step

Posted: Tue May 20, 2014 10:57 pm
by ted
If you want to sample dependent variables at 4 ms intervals, why bother recording time at all?
If, however, you want to capture the dependent variables and the corresponding time every time your simulation generates a new solution, use the plain vanilla
vdest.record(&var)
syntax for each variable you want to record. Note that there must be at least one section in order for t to be recorded.

Re: How to save the time at each time step

Posted: Wed May 21, 2014 9:43 am
by breakwave922
Thank you very much for your kindly reply.
Let me explain my situation: In my model, I recorded the soma voltage with 4ms time_step, the total time length of the model is 1100ms. If the voltage was recorded from 0ms, then the vector should contain 1100/4 + 1 = 278 values. But what I got is 277 values. So I want to know at what time the voltage was recorded, and at what time, the recording was ended.
Then I tried to recorded the time variables at 4ms intervals, in parallel with the voltage recording, in order to figure out the time courses.

Re: How to save the time at each time step

Posted: Wed May 21, 2014 11:35 am
by ted
1100/4 = 275
Total number of points captured at 4 ms intervals, starting at 0 and ending at 1100, will be 276. I just tried that myself using this file

Code: Select all

load_file("stdrun.hoc")
create soma
access soma
objref v4vec
v4vec = new Vector()
v4vec.record(&v(0.5), 4)
tstop = 1100
run()
print "number: ", v4vec.size()
which I called test.hoc.
nrniv test.hoc
produced this output:
number: 276

Re: How to save the time at each time step

Posted: Wed May 21, 2014 11:55 am
by breakwave922
Sorry, my typo. It supposed to be 1100/4 + 1 = 276. But what I got is 1100/4 = 275. I don't know why.

Re: How to save the time at each time step

Posted: Wed May 21, 2014 12:07 pm
by ted
What is your code using for dt? What happens when you do exactly what I did in my previous post?

Re: How to save the time at each time step

Posted: Wed May 21, 2014 12:38 pm
by breakwave922
I got the same number as you got in your previous post.
My dt is the model is 0.05

Re: How to save the time at each time step

Posted: Wed May 21, 2014 6:30 pm
by ted
Suggest you run a simulation using your dt.
At the end of the simulation, execute this statement
print t - 1100
and see what value is returned.