lti transient response analysis using Python(numpy, scipy, matplotlib)에 다음 코드가 있습니다. 나는 파이썬으로 새롭다. 나는 플롯해야하는 전달 행렬을 가지고있다.ValueError ("분모 다항식은 랭크 -1 배열이어야합니다.")
나는 mathwork: tf을 발견했습니다.
from numpy import min, max
from scipy import linspace
from scipy.signal import lti, step, impulse
num00 = [0.0]
den00 = [0.0]
num01 = [-2383.3]
den01 = [1.0,160.3460,-1962.0,-314598.852]
num10 = [1.0]
den10 = [1.0]
num11 = [31.9361,0,111320.0]
den11 = [1.0,160.3460,-1962.0,-314598.852]
num = [[num00,num01],[num10,num11]]
den = [[den00,den01],[den10,den11]]
tf = lti(num,den)
t = 0
s = 0
# get t = time, s = unit-step response
t , s = step(tf)
t , s = step(tf, T = linspace(min(t), t[-1], 1000))
t , i = impulse(tf, T = linspace(min(t), t[-1], 1000))
from matplotlib import pyplot as plt
plt.plot(t, s, t, i)
plt.title('Transient-Response Analysis')
plt.xlabel('Time(sec)')
plt.ylabel('Amplitude')
plt.hlines(1, min(t), max(t), colors='r')
plt.hlines(0, min(t), max(t))
plt.xlim(xmax=max(t))
plt.legend(('Unit-Step Response', 'Unit-Impulse Response'), loc=0)
plt.grid()
plt.show()
을 나는 오류가 다음 무엇입니까 : 문제의
>>> tf = lti(num,den)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python26\lib\site-packages\scipy\signal\ltisys.py", line 236, in __init__self.__dict__['num'], self.__dict__['den'] = normalize(*args)
File "C:\Python26\lib\site-packages\scipy\signal\filter_design.py", line 276, in normalize raise ValueError("Denominator polynomial must be rank-1 array.") ValueError: Denominator polynomial must be rank-1 array.
링크 된 블로그에 대한 귀하의 의견에 대한 답변에 의하면, 목록이 아닌'numpy.array'가 필요합니다. 당신은가 t픈 튜토리얼을 들으셨습니까? – geoffspear
'num00 np.array = (0.0) = den00 np.array (0.0) num01 = np.array (-2383.3) den01 np.array = ([1.0,160.3460, -1962.0, -314598.852]) num10 np.array = ([1.0]) den10 np.array = ([1.0]) num11 np.array = ([31.9361,0,111320.0]) = den11 np.array를 ([1.0,160.3460, -1962.0, -314598.852] num0010 = np.array ([num00, num10]) num0011 = np.array ([num01, num11])'여기에서 해당 목록 만. 변수가 배열로 변경 될 수없는 것 같습니다. – Rick2047
이제 num : np.array ([[[0.0], [1.0]], [[- 2383.3], [31.9361,0,111320.0]]) den = np.array ([[ [num], [1.0], [1.0,160.3460, -1962.0, -314598.852], [1.0,160.3460, -1962.0, -314598.852]]) tf = lti (num, den) 같은. : | – Rick2047