Fitzhugh-Nagumo 模型的这个 C 实现有什么错误?

What is the mistake in this C implementation of Fitzhugh-Nagumo model?

我已经为 Fitzhugh-Nagumo 模型实现了一个 MATLAB 代码并得到了绘图,但是当我将它翻译成如下所示的 C 代码时,它没有给我正确的输出。具体来说,神经元不会发出尖峰信号。谁能指出错误?

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
double rand2(void);
int main()
{
    int n,i;
    double dt,r[120000],g[120000],rr ;// 20min = 20*60/dt = 120000
    double a=0.08,b=0.7,c=0.8,gg;
    //FILE * temp = fopen("fhn.dat", "w");
    srand(time(NULL));
    //T=200*60;
    dt=0.01;
    r[0]=-0.212002413260425;//initial values
    g[0]=-0.869601930608358;

    for(n=1;n<=120000;n++)
    {
    r[n]=(dt)*((a*g[n-1])+b-(c*r[n-1]))+r[n-1];
    rr=rand2(); //uniform random number between 0 and 1
    gg=pow(g[n-1],3); // g[n-1]^3
    g[n]=(dt)*(g[n-1]-gg-r[n-1]+rr)+g[n-1];
    //printf("rr %f\n",rr);
    }

    FILE *gnuplot = popen("gnuplot -persistent", "w");
    fprintf(gnuplot, "set title \"Fitzhugh-Nagumo\" \n");
    fprintf(gnuplot, "plot '-' with lines \n");
    for (i=0;i<=120000-1;i++)
    {
        fprintf(gnuplot, "%g %g\n", r[i],g[i]);
        //fprintf(temp, "%lf %lf \n",r[i], g[i]); //Write the data to a temporary file

    }
    fprintf(gnuplot, "e\n");
    fflush(gnuplot);
    pclose(gnuplot);
    //fclose(temp);
    return 0;
}

double rand2()
{
    return (double)rand() / (double)RAND_MAX ;
}

注意:我希望得到如下图所示的输出:

更新:Link到MATLAB Code

但我得到的是这样的:

r[n] 括号错误。替换

r[n]=(dt)*((a*g[n-1])+b-(c*r[n-1]))+r[n-1];

r[n]=(dt)*(a*(g[n-1]+b-c*r[n-1]))+r[n-1];

结果与预期一致。