Skip to content

Commit 4084ae8

Browse files
committed
Fix warnings in test-reponse.py example
1 parent fea51c0 commit 4084ae8

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

examples/test-response.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import os
55
import matplotlib.pyplot as plt # MATLAB plotting functions
66
from control.matlab import * # Load the controls systems library
7-
from scipy import arange # function to create range of numbers
7+
from numpy import arange # function to create range of numbers
8+
9+
from control import reachable_form
810

911
# Create several systems for testing
1012
sys1 = tf([1], [1, 2, 1])
@@ -13,10 +15,18 @@
1315
# Generate step responses
1416
(y1a, T1a) = step(sys1)
1517
(y1b, T1b) = step(sys1, T=arange(0, 10, 0.1))
16-
(y1c, T1c) = step(sys1, X0=[1, 0])
18+
# convert to reachable canonical SS to specify initial state
19+
sys1_ss = reachable_form(ss(sys1))[0]
20+
(y1c, T1c) = step(sys1_ss, X0=[1, 0])
1721
(y2a, T2a) = step(sys2, T=arange(0, 10, 0.1))
1822

19-
plt.plot(T1a, y1a, T1b, y1b, T1c, y1c, T2a, y2a)
23+
plt.plot(T1a, y1a, label='$g_1$ (default)', linewidth=5)
24+
plt.plot(T1b, y1b, label='$g_1$ (w/ spec. times)', linestyle='--')
25+
plt.plot(T1c, y1c, label='$g_1$ (w/ init cond.)')
26+
plt.plot(T2a, y2a, label='$g_2$ (w/ spec. times)')
27+
plt.xlabel('time')
28+
plt.ylabel('output')
29+
plt.legend()
2030

2131
if 'PYCONTROL_TEST_EXAMPLES' not in os.environ:
22-
plt.show()
32+
plt.show()

0 commit comments

Comments
 (0)