【发布时间】:2015-01-21 10:52:05
【问题描述】:
我是 Python 和 Scipy 的新手。目前我正在尝试在 matplotlib 中绘制 p 型晶体管传输曲线。它是分段定义的,我正在努力寻找一种获得结果曲线的好方法。到目前为止我所拥有的是:
import matplotlib.pyplot as plt
import numpy as np
from scipy.constants import epsilon_0
V_GS = np.linspace(-15, 10, 100) # V
V_th = 1.9 # V
V_DS = -10 # V
mu_p = 0.1e-4 # m²/Vs
epsilon_r = 7.1
W = 200e-6 # m
L = 10e-6 # m
d = 70e-9 # m
C_G = epsilon_0*epsilon_r/d
beta = -mu_p*C_G*W/L
Ids_cutoff = np.empty(100); Ids_cutoff.fill(-1e-12)
Ids_lin = beta*((V_GS-V_th)*V_DS-V_DS**2/2)
Ids_sat = beta*1/2*(V_GS-V_th)**2
plt.plot(V_GS, Ids_lin, label='lin')
plt.plot(V_GS, Ids_sat, label='sat')
plt.plot(V_GS, Ids_cutoff, label='cutoff')
plt.xlabel('V_GS [V]')
plt.ylabel('I [A]')
plt.legend(loc=0)
plt.show()
这给了我整个 V_GS 范围内的三个曲线。现在我想定义
Ids = Ids_cutoff for V_GS >= V_th
Ids = Ids_lin for V_GS < V_th; V_DS >= V_GS - V_th
Ids = Ids_sat for V_GS < V_th; V_DS < V_GS - V_th
我找到了 np.vectorize() 的示例,但不知何故,我一直在努力理解如何使用这些数组。我可以创建一个遍历所有值的 for 循环,但我很确定有更有效的方法可以做到这一点。
除了导出 Ids 的值列表并将其与 V_GS 进行绘图之外,是否还可以将 matplotlib 的三个方程分段绘制为一条曲线?
【问题讨论】:
标签: python numpy matplotlib plot scipy