Exemplo n.º 1
0
def tb03ad_example():
    A = array([ [1, 2, 0],
                [4,-1, 0],
                [0, 0, 1]])
    B = array([ [1, 0],
                [0, 0],
                [1, 0]])
    C = array([ [0, 1,-1],
                [0, 0, 1]])
    D = array([ [0, 1],
                [0, 0]])
    n = 3
    m = 1
    p = 2
    out = slycot.tb03ad(n,m,p,A,B,C,D,'R')
    #out = slycot.tb03ad_l(n,m,p,A,B,C,D)
    print('--- Example for tb03ad ...')
    print('The right polynomial representation of' )
    print('    W(z) = C(zI-A)^-1B + D')
    print('is the following:' )
    print('index', out[4])
    k_max = max(out[4]) + 1
    for k in range(0,k_max):
        print('P_%d =' %(k))
        print(out[5][0:m,0:m,k])
    for k in range(0,k_max):
        print('Q_%d =' %(k))
        print(out[6][0:m,0:p,k])
Exemplo n.º 2
0
def tc04ad_example():
    from numpy import shape,zeros
    A = array([ [1, 2, 0],
                [4,-1, 0],
                [0, 0, 1]])
    B = array([ [1, 0],
                [0, 0],
                [1, 0]])
    C = array([ [0, 1,-1],
                [0, 0, 1]])
    D = array([ [0, 1],
                [0, 0]])
    n = 3
    m = 1
    p = 2
    out = slycot.tb03ad(n,m,p,A,B,C,D,'R')
    qcoeff = zeros((max(m,p),max(m,p),shape(out[6])[2]))
    qcoeff[0:shape(out[6])[0],0:shape(out[6])[1],0:shape(out[6])[1]]
    out2 = slycot.tc04ad(m,p,out[4],out[5][0:m,0:m,:],qcoeff,'R')
    print('--- Example for tb04ad ...')
    print('The system has a state space realization (A,B,C,D) where')
    print('A =')
    print(out2[1])
    print('B =')
    print(out2[2])
    print('C =')
    print(out2[3])
    print('D =')
    print(out2[4])
Exemplo n.º 3
0
def tc04ad_example():
    from numpy import shape,zeros
    A = array([ [1, 2, 0],
                [4,-1, 0],
                [0, 0, 1]])
    B = array([ [1, 0],
                [0, 0],
                [1, 0]])
    C = array([ [0, 1,-1],
                [0, 0, 1]])
    D = array([ [0, 1],
                [0, 0]])
    n = 3
    m = 1
    p = 2
    out = slycot.tb03ad(n,m,p,A,B,C,D,'R')
    qcoeff = zeros((max(m,p),max(m,p),shape(out[6])[2]))
    qcoeff[0:shape(out[6])[0],0:shape(out[6])[1],0:shape(out[6])[1]]
    out2 = slycot.tc04ad(m,p,out[4],out[5][0:m,0:m,:],qcoeff,'R')
    print('--- Example for tb04ad ...')
    print('The system has a state space realization (A,B,C,D) where')
    print('A =')
    print(out2[1])
    print('B =')
    print(out2[2])
    print('C =')
    print(out2[3])
    print('D =')
    print(out2[4])
Exemplo n.º 4
0
def tb03ad_example():
    A = array([ [1, 2, 0],
                [4,-1, 0],
                [0, 0, 1]])
    B = array([ [1, 0],
                [0, 0],
                [1, 0]])
    C = array([ [0, 1,-1],
                [0, 0, 1]])
    D = array([ [0, 1],
                [0, 0]])
    n = 3
    m = 1
    p = 2
    out = slycot.tb03ad(n,m,p,A,B,C,D,'R')
    #out = slycot.tb03ad_l(n,m,p,A,B,C,D)
    print('--- Example for tb03ad ...')
    print('The right polynomial representation of' )
    print('    W(z) = C(zI-A)^-1B + D')
    print('is the following:' )
    print('index', out[4])
    k_max = max(out[4]) + 1
    for k in range(0,k_max):
        print('P_%d =' %(k))
        print(out[5][0:m,0:m,k])
    for k in range(0,k_max):
        print('Q_%d =' %(k))
        print(out[6][0:m,0:p,k])
Exemplo n.º 5
0
def minreal(sys):
    """Minimal representation for state space systems

    Usage
    =====
    [sysmin]=minreal[sys]

    Inputs
    ------

    sys: system in ss or tf form

    Outputs
    -------
    sysfin: system in state space form
    """
    a=mat(sys.A)
    b=mat(sys.B)
    c=mat(sys.C)
    d=mat(sys.D)
    nx=shape(a)[0]
    ni=shape(b)[1]
    no=shape(c)[0]

    out=tb03ad(nx,no,ni,a,b,c,d,'R')

    nr=out[3]
    A=out[0][:nr,:nr]
    B=out[1][:nr,:ni]
    C=out[2][:no,:nr]
    sysf=ss(A,B,C,sys.D,sys.Tsamp)
    return sysf
def minreal(sys):
    """Minimal representation for state space systems

    Usage
    =====
    [sysmin]=minreal[sys]

    Inputs
    ------

    sys: system in ss or tf form

    Outputs
    -------
    sysfin: system in state space form
    """
    sys=ss(sys)
    a=mat(sys.A)
    b=mat(sys.B)
    c=mat(sys.C)
    d=mat(sys.D)
    nx=shape(a)[0]
    ni=shape(b)[1]
    no=shape(c)[0]
    if no<ni:
        c=vstack((c,zeros((ni-no,nx))))
        d=vstack((d,zeros((ni-no,ni))))
    if ni<no:
        b=hstack((b,zeros((nx,no-ni))))
        d=hstack((d,zeros((no,no-ni))))
 
    print nx
    print ni
    print no
    print a
    print b
    print c
    print d

    out=tb03ad(nx,ni,no,a,b,c,d,'R')

    nr=out[3]
    A=out[0][:nr,:nr]
    B=out[1][:nr,:ni]
    C=out[2][:no,:nr]
    sysf=ss(A,B,C,sys.D,sys.Tsamp)
    return sysf
Exemplo n.º 7
0
def minreal(sys):
    """Minimal representation for state space systems

    Usage
    =====
    [sysmin]=minreal[sys]

    Inputs
    ------

    sys: system in ss or tf form

    Outputs
    -------
    sysfin: system in state space form
    """
    a = mat(sys.A)
    b = mat(sys.B)
    c = mat(sys.C)
    d = mat(sys.D)
    nx = shape(a)[0]
    ni = shape(b)[1]
    no = shape(c)[0]
    if no < ni:
        c = vstack((c, zeros((ni - no, nx))))
        d = vstack((d, zeros((ni - no, ni))))
    if ni < no:
        b = hstack((b, zeros((nx, no - ni))))
        d = hstack((d, zeros((no, no - ni))))
    out = tb03ad(nx, ni, no, a, b, c, d, 'R')

    nr = out[3]
    A = out[0][:nr, :nr]
    B = out[1][:nr, :ni]
    C = out[2][:no, :nr]
    sysf = ss(A, B, C, sys.D, sys.Tsamp)
    return sysf