Exemple #1
0
def bode_diagram():
    a=[]
    b=[]
    print("分子の最高次は?")
    bunshi = int(input("入力:"))
    print("分子の高次の項の係数を入れてください")
    for i in range(bunshi+1):
        print("s^",(bunshi-i),"の係数を入力してください",sep='')
        a.append(float(input("入力:")))
    print('\n')    
    print("分母の最高次は?")
    bunbo = int(input("入力:"))
    print("分母の高次の項の係数を入れてください")
    for i in range(bunbo+1):
        print("s^",(bunbo-i),"の係数を入力してください",sep='')
        b.append(float(input("入力:")))
    print('\n')  

    Ga=matlab.tf(a,b)
    print(Ga)
    fig=plt.figure()
    matlab.bode(Ga)
    plt.show()
    fig.savefig("ボード線図.jpg")
    fig = plt.figure()
    matlab.nyquist(Ga)
    plt.show()
    fig.savefig("ナエキスト線図")
    def analysis(self, w, block, which):
        nume = [int(n) for n in block.nume_coef]
        if block.deno_coef == []:
            deno = [1]
        else:
            deno = [int(d) for d in block.deno_coef]
        nume.reverse()
        deno.reverse()
        print(nume)
        print(deno)
        system = matlab.tf(nume, deno)

        if which == 'bode':
            matlab.bode(system)
            plt.show()
        elif which == 'rlocus':
            matlab.rlocus(system)
            plt.show()
        elif which == 'nyquist':
            matlab.nyquist(sys)
            plt.show()
        elif which == 'impulse':
            t = np.linspace(0, 3, 1000)
            yout, T = matlab.impulse(system, t)
            plt.plot(T, yout)
            plt.axhline(0, color="b", linestyle="--")
            plt.xlim(0, 3)
            plt.show()
        elif which == 'step':
            t = np.linspace(0, 3, 1000)
            yout, T = matlab.step(system, t)
            plt.plot(T, yout)
            plt.axhline(1, color="b", linestyle="--")
            plt.xlim(0, 3)
            plt.show()
 def testNyquist(self, siso):
     """Call nyquist()"""
     nyquist(siso.ss1)
     nyquist(siso.tf1)
     nyquist(siso.tf2)
     w = logspace(-3, 3)
     nyquist(siso.tf2, w)
     (real, imag, freq) = nyquist(siso.tf2, w, plot=False)
Exemple #4
0
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 test_matlab_freqplot_passthru(self, mplcleanup):
     """Test nyquist and bode to make sure the pass arguments through"""
     sys = tf([1], [1, 2, 1])
     bode((sys,))            # Passing tuple will call bode_plot
     nyquist((sys,))         # Passing tuple will call nyquist_plot
Exemple #6
0
t = np.linspace(0, 3, 1000)
yout, T = matlab.step(sys, t)
plt.plot(T, yout)
plt.axhline(1, color="b", linestyle="--")
plt.xlim(0, 3)
plt.show()

# impulse response
yout, T = matlab.impulse(sys, t)
plt.plot(T, yout)
plt.axhline(0, color="b", linestyle="--")
plt.xlim(0, 3)
#plt.show()

# nyquist diagram
matlab.nyquist(sys)
#plt.show()

# bode diagram
matlab.bode(sys)
#plt.show()

# root locus
matlab.rlocus(sys)
#plt.show()

# pole
matlab.pole(sys)
#plt.show()

# margin