import math
import matplotlib.pyplot as plt
import numpy as np
D = 100
R = 10
d = 25
ts = 1
def f(t):
return (R / d) * math.erfc((d - R) / math.sqrt(4 * D * t))
def p(k, ts):
return f((k + 1) * ts) - f(k * ts)
x = np.linspace(1, 20, 20)
y = p(x, ts)
plt.xlabel("N")
plt.ylabel("P")
plt.plot(x, y)
plt.show()
Traceback (most recent call last):
File "C:/Users/ZJUT/PycharmProjects/test/graph.py", line 21, in
y = p(x, ts)
File "C:/Users/ZJUT/PycharmProjects/test/graph.py", line 17, in p
return f((k + 1) * ts) - f(k * ts)
File "C:/Users/ZJUT/PycharmProjects/test/graph.py", line 13, in f
return (R / d) * math.erfc((d - R) / math.sqrt(4 * D * t))
TypeError: only size-1 arrays can be converted to Python scalars