def test_plot(sys): fig = plt.figure(facecolor='w') mag, phase, omega = matlab.bode(sys) fig = plt.figure(facecolor='w') real, imag, freq = matlab.nyquist(sys) fig = plt.figure(facecolor='w') matlab.nichols(sys) rlist, klist = matlab.rlocus(sys, klist=None) # fig = plt.figure(facecolor = 'w') # #对数幅相特性曲线 # ax = fig.add_subplot(221) # ax.grid(True) ## real = mag*np.sin(phase) ## imag = mag*np.cos(phase) # plt.plot(real, imag) # ax = fig.add_subplot(223) # ax.grid(True) # real = np.log(mag)*np.sin(phase) # imag = np.log(mag)*np.cos(phase) # plt.plot(real, imag) # #对数频率特性曲线 # ax = fig.add_subplot(222) # ax.grid(True) # plt.plot(np.log(omega), np.log(mag)) # ax = fig.add_subplot(224) # ax.grid(True) # plt.plot(np.log(omega), phase) plt.show()
def testNichols_ngrid(self, siso, mplcleanup): """Call nichols() and ngrid()""" nichols(siso.tf2, grid=False) ngrid()
def testNichols_logspace(self, siso, mplcleanup): """Call nichols() with logspace w""" w = logspace(-3, 3) nichols(siso.tf2, w)
def testNichols(self, siso, subsys, mplcleanup): """Call nichols()""" nichols(getattr(siso, subsys))
#G = ml.tf([1], [1, 1]) num = [100] den = [1, 11, 10] sys = signal.TransferFunction(num, den) G = ml.tf(num, den) print(sys) #print(ml.pole(sys)) #print(ml.zero(sys)) fig = plt.figure(0) plt.xlabel('Frequência [rad/s]') plt.ylabel('Magnitude [dB]') #magnitude, fase, w = ml.bode(G, dB = True) w, mag, phase = signal.bode(sys) plt.semilogx(w, mag) plt.grid(True, which='both') #plt.plot() plt.figure(1) plt.xlabel('Frequência [rad/s]') plt.ylabel('Fase [°]') plt.semilogx(w, phase) plt.grid(True, which='both') plt.figure(2) ml.nichols(G) plt.plot() plt.show()