我得到以下错误:
line 113, in derivatives
dx[0] = (noisyInput + stim(z)-g_NA*np.power(m,3.0)*h*(V-V_NA)-g_k*np.power(n,4.0)*(V-V_K)-g_L*(V-V_L))/1.0
ValueError: setting an array element with a sequence.
请查看随附的代码
import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import odeint
#runtime in milliseconds
#print("Type in the runtime-interval (in milliseconds)")
#t_0 = input()
#t_1 = input()
t_0 = 0.0
t_1 = 200.0
print("The interval of runtime is:")
print(t_0, t_1)
#Potassium (alpha_n, beta_n) and Sodium (alpha_m, beta_m, alpha_h, beta_h) ion-channel rate functions
def alpha_n(V):
return (0.01*(10.0-V))/(np.exp((10.0-V)/10.0)-1.0)
def alpha_m(V):
return (0.1*(25.0-V))/(np.exp((25.0-V)/10.0)-1)
def beta_n(V):
return 0.125*np.exp(-V/80.0)
def beta_m(V):
return 4.0*np.exp(-V/18.0)
def alpha_h(V):
return 0.07*np.exp(-V/20.0)
def beta_h(V):
return (1.0)/((np.exp((30.0-V)/10.0))+1)
#mostly used parameters
#Sodium potential (mV)
V_NA = 50.0
#Potassium Potential
V_K = -77.0
#Leak Potential
V_L = -54.4
#Potassium channel conductance
g_k = 36.0
#Sodium channel conductance
g_NA = 120.0
#Leak channel conductance
g_L = 0.3
#Membrane capacitance
C = 1.0
#equally ('distributed') time values
T = np.linspace(t_0,t_1,10000)
#please input the stimulus (first of all with a fixed stimulus)
#one spike below
def stim(t):
if 0.0 < t < 1.0:
return 150.0
elif 35.0 < t < 36.0 :
return 5000.0
return 0.0
#steady - state values
def n_infty(V = 0.0):
return alpha_n(V)/(alpha_n(V)+beta_n(V))
def m_infty(V = 0.0):
return alpha_m(V)/(alpha_m(V)+beta_m(V))
def h_infty(V = 0.0):
return alpha_h(V)/(alpha_h(V)+beta_h(V))
def tau_m(V = 0.0):
return 1.0/(alpha_m(V)+beta_m(V))
def tau_n(V = 0.0):
return 1.0/(alpha_n(V)+beta_n(V))
def tau_h(V = 0.0):
return 1.0/(alpha_h(V)+beta_h(V))
#noisy Input
noisyInput = np.random.normal(0,1, len(T))
#derivatives
def derivatives(x, z, noisyInput):
dx = np.zeros((4,))
V = x[0]
m = x[1]
n = x[2]
h = x[3]
dx[0] = (noisyInput + stim(z)-g_NA*np.power(m,3.0)*h*(V-V_NA)-g_k*np.power(n,4.0)*(V-V_K)-g_L*(V-V_L))/1.0
dx[1] = (m_infty(V)-m)/tau_m(V)
dx[2] = (n_infty(V)-n)/tau_n(V)
dx[3] = (h_infty(V)-h)/tau_h(V)
return dx
X = np.array([0.0,m_infty(),n_infty(),h_infty()])
V_x = odeint(derivatives,X,T, args=(noisyInput,))
print(V_x)
plt.plot(T,V_x)
plt.xlabel('Time in ms')
plt.ylabel('Membrane Potential in mV')
我用数组试过了,但也没用
先谢谢你 致意
目前没有回答
相关问题 更多 >
编程相关推荐