如何衡量时间间隔?

时间:2016-12-05 19:15:36

标签: c

我有一个神经元射击的模型。 c代码中有很多变量,但我感兴趣的是电压。我想跟踪神经元发射多长时间,一旦神经元达到某个值(此处为-20 mV),它肯定会发射。我附上了一张照片 - 我想特别跟踪绿色部分。我猜你用时间fxn但是我不确定怎么样? enter image description here

x [i]代表电压。这是dx [i]

的等式
swagger project start

1 个答案:

答案 0 :(得分:1)

试试这个:

int t1 = time(0);
fire_neuron();     // place the "neuron firing" code here
int t2 = time(0);

printf("Seconds taken to fire neuron: %d\n", t2 - t1);

如果你想“正确”地做,你可以#include <time.h>并像这样写:

time_t t1 = time(NULL);
fire_neuron();            // place the "neuron firing" code here
time_t t2 = time(NULL);

printf("Seconds taken to fire neuron: %f\n", difftime(t2, t1));

由于我看不到你的代码,我不确切知道如何帮助你。也许你想要像...这样的东西。

if (dx[i] <= -20) {
    time_t t1 = time(NULL);
    fire_neuron();
    time_t t2 = time(NULL);
}

printf("Seconds taken to fire neuron: %f\n", difftime(t2, t1));
相关问题