Utils tf2ss providing incorrect shape of C matrix
Closed this issue · 1 comments
92215302 commented
With the previous version of utils it was not possible to generate the state-space representation for the scaled transfer function in the attachment. The updated version permits this, however the shape of C is incorrect. The following code reproduces the problem:
import numpy as np
import utils
s = utils.tf([1, 0], 1)
G = utils.mimotf([
[0.66/(6.7*s + 1), -0.61/(8.64*s + 1), -0.0049/(9.06*s + 1)],
[1.11/(3.25*s + 1), -2.36/(5.0*s + 1), -0.012/(7.09*s + 1)],
[-34.68/(8.15*s + 1), 46.2/(10.9*s + 1), 0.87*(11.61*s + 1)/((3.89*s + 1)*(18.8*s + 1))]
])
A, B, C, D = utils.tf2ss(G)
Nstates = A.shape[0]
Ninputs = B.shape[1]
Noutputs = C.shape[0]
assert A.shape[0] == A.shape[1], "A must be square"
assert B.shape[0] == Nstates, "B must have the same number of rows as A"
assert C.shape[1] == Nstates, "C must have the same number or columns as A"
assert D.shape[0] == Ninputs, "D must have the same number of rows as C"
alchemyst commented
I've tracked the problem down to the implementation of the M matrix in tf2ss
. The source for the algorithm is no longer online, but I've made a copy which you should be able to access here.
I have added the test function to the repository in edd82f8 for anyone wanting to take this on. @NicVDMey this may also be related to the GCD/LCM issue we've been discussing.