Skip to content

step_info error for MIMO system  #574

Description

@juanodecc

I try with this MIMO system, the function broke at line 614. The step_info function convert the system to SIMO, but cannot calculate the step response characteristic parameters.

from control import ss step_response step_info

A = [[0.68, -0.34], [0.34, 0.68]];
B = [[0.18, -0.05], [0.04, 0.11]];
C = [[0, -1.53], [-1.12, -1.10]];
D = [[0, 0], [0.06, -0.37]];
m_sys = ss(A,B,C,D,0.2);
mt,my=step_response(m_sys)

step_info(m_sys)

File ".../timeresp.py", line 614, in step_info
if((yout[i] <= inf_margin) | (yout[i] >= sup_margin)):

IndexError: index 24 is out of bounds for axis 0 with size 2

Activity

  1. bnavigator commented on Mar 16, 2021

    @bnavigator
    Contributor

    Why line 614? Current master has that line at 807, Your own PR #567 duplicates it in 807 and 817.

    Can confirm with current master. The problem is the indexing of yout:

    [ben@skylab:~/src/python-control]% python3                                                                                                                       [0]
    Python 3.8.8 (default, Feb 19 2021, 16:53:21) [GCC] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from control import ss, step_response, step_info
    >>> 
    >>> A = [[0.68, -0.34], [0.34, 0.68]];
    >>> B = [[0.18, -0.05], [0.04, 0.11]];
    >>> C = [[0, -1.53], [-1.12, -1.10]];
    >>> D = [[0, 0], [0.06, -0.37]];
    >>> m_sys = ss(A,B,C,D,0.2);
    >>> mt,my=step_response(m_sys)
    >>> mt.shape
    (25,)
    >>> my.shape
    (2, 2, 25)
    >>> step_info(m_sys)
    /home/ben/src/python-control/control/statesp.py:1549: UserWarning: Converting MIMO system to SIMO system. Only input 0 is used.
      warn("Converting MIMO system to SIMO system. "
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/ben/src/python-control/control/timeresp.py", line 807, in step_info
        if((yout[i] <= inf_margin) | (yout[i] >= sup_margin)):
    IndexError: index 24 is out of bounds for axis 0 with size 2
    
  2. bnavigator commented on Mar 16, 2021

    @bnavigator
    Contributor

    Why not adjust #567 to handle MIMO systems the way MATLAB's stepinfo does:

    For a MIMO system, stepinfo returns a structure array in which each entry contains the response characteristics of the corresponding I/O channel of the system. For this example, use a two-output, two-input discrete-time system. Compute the step-response characteristics.

  3. juanodecc commented on Mar 16, 2021

    @juanodecc
    ContributorAuthor

    Why line 614? Current master has that line at 807, Your own PR #567 duplicates it in 807 and 817.

    Can confirm with current master. The problem is the indexing of yout:

    [ben@skylab:~/src/python-control]% python3                                                                                                                       [0]
    Python 3.8.8 (default, Feb 19 2021, 16:53:21) [GCC] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from control import ss, step_response, step_info
    >>> 
    >>> A = [[0.68, -0.34], [0.34, 0.68]];
    >>> B = [[0.18, -0.05], [0.04, 0.11]];
    >>> C = [[0, -1.53], [-1.12, -1.10]];
    >>> D = [[0, 0], [0.06, -0.37]];
    >>> m_sys = ss(A,B,C,D,0.2);
    >>> mt,my=step_response(m_sys)
    >>> mt.shape
    (25,)
    >>> my.shape
    (2, 2, 25)
    >>> step_info(m_sys)
    /home/ben/src/python-control/control/statesp.py:1549: UserWarning: Converting MIMO system to SIMO system. Only input 0 is used.
      warn("Converting MIMO system to SIMO system. "
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/ben/src/python-control/control/timeresp.py", line 807, in step_info
        if((yout[i] <= inf_margin) | (yout[i] >= sup_margin)):
    IndexError: index 24 is out of bounds for axis 0 with size 2
    

    yes my bad, is line 614 for version 8.4

  4. juanodecc commented on Mar 16, 2021

    @juanodecc
    ContributorAuthor

    Why not adjust #567 to handle MIMO systems the way MATLAB's stepinfo does:

    For a MIMO system, stepinfo returns a structure array in which each entry contains the response characteristics of the corresponding I/O channel of the system. For this example, use a two-output, two-input discrete-time system. Compute the step-response characteristics.

    Yes, I am trying to fix it, but I commit a partial solution for now. That improve the performance of this function

  5. juanodecc commented on Mar 16, 2021

    @juanodecc
    ContributorAuthor

    Why not adjust #567 to handle MIMO systems the way MATLAB's stepinfo does:

    For a MIMO system, stepinfo returns a structure array in which each entry contains the response characteristics of the corresponding I/O channel of the system. For this example, use a two-output, two-input discrete-time system. Compute the step-response characteristics.

    step_response have limitations, that function can solve only SIMO systems. My idea is convert the step_info into two functions: step_info4data (t, y, yfinal) for multidimentional, time and output parameters, in the other hand, keep a step_info(sys) as is, but that function can call step_info4data () with the proper input vector for MIMO systems. This can allow use the step_info4data function with time vectors and output vectors imported from externals simulation or system stimulation

  6. bnavigator commented on Mar 16, 2021

    @bnavigator
    Contributor

    I might be missing something, but the current step_response can handle MIMO. See my.shape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions