Skip to content

step_info error for MIMO system #574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
juanodecc opened this issue Mar 16, 2021 · 6 comments · Fixed by #577
Closed

step_info error for MIMO system #574

juanodecc opened this issue Mar 16, 2021 · 6 comments · Fixed by #577

Comments

@juanodecc
Copy link
Contributor

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

@bnavigator
Copy link
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

@bnavigator
Copy link
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.

@juanodecc
Copy link
Contributor Author

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

@juanodecc
Copy link
Contributor Author

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

@juanodecc
Copy link
Contributor Author

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

@bnavigator
Copy link
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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants