How to use the control.matlab.step function in control

To help you get started, we’ve selected a few control examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-control / python-control / tests / test_control_matlab.py View on Github external
def assert_systems_behave_equal(self, sys1, sys2):
        '''
        Test if the behavior of two Lti systems is equal. Raises ``AssertionError``
        if the systems are not equal.

        Works only for SISO systems.

        Currently computes dcgain, and computes step response.
        '''
        #gain of both systems must be the same
        assert_array_almost_equal(dcgain(sys1), dcgain(sys2))

        #Results of ``step`` simulation must be the same too
        t, y1 = step(sys1)
        _t, y2 = step(sys2, t)
        assert_array_almost_equal(y1, y2)
github robertobucher / pysimCoder / Tests / ControlDesign / BallOnWheel / BoWKane.py View on Github external
def plot_Res(t, y, g):
    Y,T = mt.step(g,t)
    plt.plot(T,Y)
    plt.plot(t,y)
    plt.grid()
    plt.show()
github kdavies4 / ModelicaRes / external / control / examples / tfvis.py View on Github external
self.f_bode.clf()
        plt.figure(self.f_bode.number)
        control.matlab.bode(self.sys, logspace(-2, 2))
        plt.suptitle('Bode Diagram')

        self.f_nyquist.clf()
        plt.figure(self.f_nyquist.number)
        control.matlab.nyquist(self.sys, logspace(-2, 2))
        plt.suptitle('Nyquist Diagram')

        self.f_step.clf()
        plt.figure(self.f_step.number)
        try:
            # Step seems to get intro trouble
            # with purely imaginary poles
            tvec, yvec = control.matlab.step(self.sys)
            plt.plot(tvec.T, yvec)
        except:
            print "Error plotting step response"
        plt.suptitle('Step Response')

        self.canvas_pzmap.show()
        self.canvas_bode.show()
        self.canvas_step.show()
        self.canvas_nyquist.show()
github robertobucher / pysimCoder / Tests / ControlDesign / BallOnWheel / BoWLagrange.py View on Github external
def plot_Res(t, y, g):
    Y,T = mt.step(g,t)
    plt.plot(T,Y)
    plt.plot(t,y)
    plt.grid()
    plt.show()
github python-control / python-control / examples / rss-balred.py View on Github external
[0.],
    [0.]
])
C = np.array([[0.5, 0.6875, 0.7031, 0.5]])
D = np.array([[0.]])

# The full system
fsys = StateSpace(A, B, C, D)

# The reduced system, truncating the order by 1
n = 3
rsys = msimp.balred(fsys, n, method='truncate')

# Comparison of the step responses of the full and reduced systems
plt.figure(1)
y, t = mt.step(fsys)
yr, tr = mt.step(rsys)
plt.plot(t.T, y.T)
plt.plot(tr.T, yr.T)

# Repeat balanced reduction, now with 100-dimensional random state space
sysrand = mt.rss(100, 1, 1)
rsysrand = msimp.balred(sysrand, 10, method='truncate')

# Comparison of the impulse responses of the full and reduced random systems
plt.figure(2)
yrand, trand = mt.impulse(sysrand)
yrandr, trandr = mt.impulse(rsysrand)
plt.plot(trand.T, yrand.T, trandr.T, yrandr.T)

if 'PYCONTROL_TEST_EXAMPLES' not in os.environ:
    plt.show()
github python-control / python-control / examples / rss-balred.py View on Github external
[0.]
])
C = np.array([[0.5, 0.6875, 0.7031, 0.5]])
D = np.array([[0.]])

# The full system
fsys = StateSpace(A, B, C, D)

# The reduced system, truncating the order by 1
n = 3
rsys = msimp.balred(fsys, n, method='truncate')

# Comparison of the step responses of the full and reduced systems
plt.figure(1)
y, t = mt.step(fsys)
yr, tr = mt.step(rsys)
plt.plot(t.T, y.T)
plt.plot(tr.T, yr.T)

# Repeat balanced reduction, now with 100-dimensional random state space
sysrand = mt.rss(100, 1, 1)
rsysrand = msimp.balred(sysrand, 10, method='truncate')

# Comparison of the impulse responses of the full and reduced random systems
plt.figure(2)
yrand, trand = mt.impulse(sysrand)
yrandr, trandr = mt.impulse(rsysrand)
plt.plot(trand.T, yrand.T, trandr.T, yrandr.T)

if 'PYCONTROL_TEST_EXAMPLES' not in os.environ:
    plt.show()
github robertobucher / pysimCoder / Tests / ControlDesign / BallOnWheel / BoWKane.py View on Github external
def residuals(p, y, t):  
    [k,alpha] = p
    g = tf(k,[1,alpha,0])
    Y,T = mt.step(g,t)
    err=y-Y
    return err