GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — control.matlab.lsim does not work for systems of order > 1 · Issue #764 · python-control/python-control

control.matlab.lsim does not work for systems of order > 1 #764

New issue
Copy link
New issue
Copy link
Closed
#765
Closed
control.matlab.lsim does not work for systems of order > 1#764
#765
Copy link
Labels
bug

Description

@jonschlipf
jonschlipf
opened on Aug 24, 2022
Issue body actions

When calling the control.matlab.lsim with a higher-order system (at least 2x2 matrices), there is a prompt:

ValueError: Parameter ``T`` must have same elements as the number of columns in input array ``U`` 

Inverting U or T does not help. Instead, it prompts a different error with matrix multiplication.
It works properly when calling control.timeresp.forced_response directly, with the "transpose" flag set to false.
The error is likely due to the transpose flag, and its implementation throughout the declaration of control.timeresp.forced_response

import numpy as np
import control
import control.matlab

time = np.linspace(0.0, 511.0e-6, 512)
DAC = np.sin(time)
ADC = np.cos(time)

input_Kalman = np.transpose(np.concatenate(([[DAC]], [[ADC]]), axis=1)[0])
Af = [[0.45768416, -0.42025511], [-0.43354791, 0.51961178]]
Bf = [[2.84368641, 52.05922305], [-1.47286557, -19.94861943]]
Cf = [[1.0, 0.0], [0.0, 1.0]]
Df = [[0.0, 0.0], [0.0, 0.0]]
ss_Kalman = control.ss(Af, Bf, Cf, Df, 1.0e-6)
x_est, _, _ = control.matlab.lsim(ss_Kalman, input_Kalman, time)

Activity

  1. bnavigator
    added
    bug
    on Aug 24, 2022
  2. bnavigator commented on Aug 24, 2022

    @bnavigator
    bnavigator
    on Aug 24, 2022
    Contributor
    More actions

    Confirmed

    In [5]: input_Kalman.shape
    Out[5]: (512, 2)
    
    In [6]: x_est, _, _ = control.matlab.lsim(ss_Kalman, input_Kalman, time)
    Traceback (most recent call last):
    
      Input In [6] in <cell line: 1>
        x_est, _, _ = control.matlab.lsim(ss_Kalman, input_Kalman, time)
    
      File ~/src/python-control/control/matlab/timeresp.py:297 in lsim
        out = forced_response(sys, T, U, X0, return_x=True, transpose=True)
    
      File ~/src/python-control/control/timeresp.py:978 in forced_response
        raise ValueError('Parameter ``T`` must have same elements as'
    
    ValueError: Parameter ``T`` must have same elements as the number of columns in input array ``U``
    
    
    In [7]: x_est, _, _ = control.matlab.lsim(ss_Kalman, input_Kalman.T, time)
    Traceback (most recent call last):
    
      Input In [7] in <cell line: 1>
        x_est, _, _ = control.matlab.lsim(ss_Kalman, input_Kalman.T, time)
    
      File ~/src/python-control/control/matlab/timeresp.py:297 in lsim
        out = forced_response(sys, T, U, X0, return_x=True, transpose=True)
    
      File ~/src/python-control/control/timeresp.py:1007 in forced_response
        U = _check_convert_array(U, legal_shapes,
    
      File ~/src/python-control/control/timeresp.py:805 in _check_convert_array
        raise ValueError(err_msg_start + err_msg)
    
    ValueError: Parameter ``U``: Wrong shape (rows, columns): (512, 2). Expected: (2, 512).
    
  3. murrayrm
    linked a pull request that will close this issuefix control.matlab.lsim bug for discrete time system #765on Aug 25, 2022
  4. bnavigator
    closed this as completedin #765on Aug 25, 2022
  5. bnavigator commented on Aug 25, 2022

    @bnavigator
    bnavigator
    on Aug 25, 2022
    Contributor
    More actions

    @murrayrm fixed it in #765

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.