Skip to content

Can't get a decent output with step_response. #473

Closed

Description

@Klarom

I have a question. Here i have a problem with plotting step response. My graphic looks like this and i have no idea whats wrong here.

import control
import numpy as np
import matplotlib.pyplot as plt
Ts = 1
G1 = control.tf([60], [1,0.1])
G2 = control.tf([0.5, 3], [1, 5, 12])
G3 = control.tf([1], [1, 5])
Gs= G1*G2*G3
Gz = control.c2d(Gs,Ts, method= 'zoh')
control.root_locus(Gz)
control.root_locus(Gs)
print(Gz)
print(Gs)

cltf=(Gs/(1+Gs))
Zcltf=(Gz/(1+Gz))

T = np.arange(0, 10)
za = control.step_response(cltf, T)

zb = control.step_response(Zcltf, T) 
plt.plot(zb)
plt.plot(za)
 

image

Activity

  1. bnavigator commented on Dec 15, 2020

    @bnavigator
    Contributor

    plt.plot expects the output in a different shape. You provide a list of two arrays with shape (10,), but it is casted by matplotlib into the wrong 2D array representing 10 curves with data from shape (2, ) each. Try to separate the time vector and response time series into different variables and call plt.plot with 2 parameters. Getting used to that will help you when you deal with systems with more than one output, where you have a time vector of length n and a response of (m, n): https://python-control.readthedocs.io/en/latest/conventions.html#time-series-data applies.

    General note: It is not wrong to ask questions here, but this is the issue tracker for the source code. There are other platforms like StackOverflow which might be better suited for questions about matplotlib, numpy or Python programming in general. Try to follow a matplotlib or numpy tutorial for the basic concepts.

  2. locked and limited conversation to collaborators on Mar 12, 2021
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions