本文整理汇总了Python中control.statesp.StateSpace.zero方法的典型用法代码示例。如果您正苦于以下问题:Python StateSpace.zero方法的具体用法?Python StateSpace.zero怎么用?Python StateSpace.zero使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类control.statesp.StateSpace
的用法示例。
在下文中一共展示了StateSpace.zero方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testZero
# 需要导入模块: from control.statesp import StateSpace [as 别名]
# 或者: from control.statesp.StateSpace import zero [as 别名]
def testZero(self):
"""Evaluate the zeros of a SISO system."""
sys = StateSpace(self.sys1.A, [[3.], [-2.], [4.]], [[-1., 3., 2.]], [[-4.]])
z = sys.zero()
np.testing.assert_array_almost_equal(z, [4.26864638637134,
-3.75932319318567 + 1.10087776649554j,
-3.75932319318567 - 1.10087776649554j])
示例2: TestStateSpace
# 需要导入模块: from control.statesp import StateSpace [as 别名]
# 或者: from control.statesp.StateSpace import zero [as 别名]
class TestStateSpace(unittest.TestCase):
"""Tests for the StateSpace class."""
def setUp(self):
"""Set up a MIMO system to test operations on."""
# sys1: 3-states square system (2 inputs x 2 outputs)
A322 = [[-3., 4., 2.],
[-1., -3., 0.],
[2., 5., 3.]]
B322 = [[1., 4.],
[-3., -3.],
[-2., 1.]]
C322 = [[4., 2., -3.],
[1., 4., 3.]]
D322 = [[-2., 4.],
[0., 1.]]
self.sys322 = StateSpace(A322, B322, C322, D322)
# sys1: 2-states square system (2 inputs x 2 outputs)
A222 = [[4., 1.],
[2., -3]]
B222 = [[5., 2.],
[-3., -3.]]
C222 = [[2., -4],
[0., 1.]]
D222 = [[3., 2.],
[1., -1.]]
self.sys222 = StateSpace(A222, B222, C222, D222)
# sys3: 6 states non square system (2 inputs x 3 outputs)
A623 = np.array([[1, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[0, 0, 3, 0, 0, 0],
[0, 0, 0, -4, 0, 0],
[0, 0, 0, 0, -1, 0],
[0, 0, 0, 0, 0, 3]])
B623 = np.array([[0, -1],
[-1, 0],
[1, -1],
[0, 0],
[0, 1],
[-1, -1]])
C623 = np.array([[1, 0, 0, 1, 0, 0],
[0, 1, 0, 1, 0, 1],
[0, 0, 1, 0, 0, 1]])
D623 = np.zeros((3, 2))
self.sys623 = StateSpace(A623, B623, C623, D623)
def test_pole(self):
"""Evaluate the poles of a MIMO system."""
p = np.sort(self.sys322.pole())
true_p = np.sort([3.34747678408874,
-3.17373839204437 + 1.47492908003839j,
-3.17373839204437 - 1.47492908003839j])
np.testing.assert_array_almost_equal(p, true_p)
def test_zero_empty(self):
"""Test to make sure zero() works with no zeros in system."""
sys = _convertToStateSpace(TransferFunction([1], [1, 2, 1]))
np.testing.assert_array_equal(sys.zero(), np.array([]))
@unittest.skipIf(not slycot_check(), "slycot not installed")
def test_zero_siso(self):
"""Evaluate the zeros of a SISO system."""
# extract only first input / first output system of sys222. This system is denoted sys111
# or tf111
tf111 = ss2tf(self.sys222)
sys111 = tf2ss(tf111[0, 0])
# compute zeros as root of the characteristic polynomial at the numerator of tf111
# this method is simple and assumed as valid in this test
true_z = np.sort(tf111[0, 0].zero())
# Compute the zeros through ab08nd, which is tested here
z = np.sort(sys111.zero())
np.testing.assert_almost_equal(true_z, z)
@unittest.skipIf(not slycot_check(), "slycot not installed")
def test_zero_mimo_sys322_square(self):
"""Evaluate the zeros of a square MIMO system."""
z = np.sort(self.sys322.zero())
true_z = np.sort([44.41465, -0.490252, -5.924398])
np.testing.assert_array_almost_equal(z, true_z)
@unittest.skipIf(not slycot_check(), "slycot not installed")
def test_zero_mimo_sys222_square(self):
"""Evaluate the zeros of a square MIMO system."""
z = np.sort(self.sys222.zero())
true_z = np.sort([-10.568501, 3.368501])
np.testing.assert_array_almost_equal(z, true_z)
@unittest.skipIf(not slycot_check(), "slycot not installed")
def test_zero_mimo_sys623_non_square(self):
"""Evaluate the zeros of a non square MIMO system."""
#.........这里部分代码省略.........