调试 NEURON 模拟器 .MOD 文件有哪些有用的方法?在其他语言中,通常可以使用 print() 语句来查看变量值。 .MOD 文件中是否有类似 print() 语句的内容?
最佳答案
使用 printf()
语句
例如,在 .MOD 文件内的任何部分中,添加下面的 printf()
语句将打印变量 t、i 和 v
值在模拟过程中评估该部分的时间:
BREAKPOINT {
SOLVE state METHOD cnexp
g = (B - A)*gmax
i = g*(v - e)
printf("time: %g, current: %g, voltage: %g \n", t, i, v)
}
将产生如下所示的结果:
time: 231.062, current: 0.000609815, voltage: -67.2939
time: 231.188, current: 0.000609059, voltage: -67.2938
time: 231.312, current: 0.000608304, voltage: -67.2937
time: 231.438, current: 0.00060755, voltage: -67.2936
time: 231.562, current: 0.000606844, voltage: -67.2924
注释:
- 添加上述语句后重新编译文件夹中的.mod文件
- 不要忘记在末尾添加“\n”以避免堆积输出
- 其他参数选项(%g 除外)可以在 printf() reference 中找到。
关于调试 NEURON MOD 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36611824/