Plotting Average curve for points in gnuplot

后端 未结 5 648
夕颜
夕颜 2020-12-19 10:03

[Current]

I am importing a text file in which the first column has simulation time (0~150) the second column has the delay (0.01~0.02).

1.000000 0.01         


        
5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-19 10:11

    Here's some replacement code for the top answer, which makes this also work for 1000+ points and much much faster. Only works in gnuplot 5.2 and later I guess

    # number of points in moving average
    n = 5000
    
    array A[n]
    
    samples(x) = $0 > (n-1) ? n : int($0+1)
    mod(x) = int(x) % n
    avg_n(x) = (A[mod($0)+1]=x, (sum [i=1:samples($0)] A[i]) / samples($0))
    

提交回复
热议问题