Skip to content

Commit 6d51358

Browse files
authored
Merge pull request #518 from roryyorke/rory/minor-fixes
Minor fixes to examples, docstrings
2 parents 122672a + 43f6403 commit 6d51358

File tree

5 files changed

+22
-15
lines changed

5 files changed

+22
-15
lines changed

control/tests/convert_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def testConvert(self, fixedseed, states, inputs, outputs):
155155
def testConvertMIMO(self):
156156
"""Test state space to transfer function conversion.
157157
158-
Do a MIMO conversation and make sure that it is processed
158+
Do a MIMO conversion and make sure that it is processed
159159
correctly both with and without slycot
160160
161161
Example from issue gh-120, jgoppert

control/timeresp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def forced_response(sys, T=None, U=0., X0=0., transpose=False,
356356
if isinstance(sys, TransferFunction) and np.any(X0 != 0):
357357
warnings.warn(
358358
"Non-zero initial condition given for transfer function system. "
359-
"Internal conversation to state space used; may not be consistent "
359+
"Internal conversion to state space used; may not be consistent "
360360
"with given X0.")
361361

362362
xout = np.zeros((n_states, n_steps))
@@ -702,7 +702,7 @@ def step_response(sys, T=None, X0=0., input=None, output=None, T_num=None,
702702
if isinstance(sys, TransferFunction) and np.any(X0 != 0):
703703
warnings.warn(
704704
"Non-zero initial condition given for transfer function system. "
705-
"Internal conversation to state space used; may not be consistent "
705+
"Internal conversion to state space used; may not be consistent "
706706
"with given X0.")
707707

708708
# Convert to state space so that we can simulate

examples/robust_mimo.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,8 @@ def analysis():
5454
g = plant()
5555

5656
t = np.linspace(0, 10, 101)
57-
_, yu1 = step_response(g, t, input=0)
58-
_, yu2 = step_response(g, t, input=1)
59-
60-
yu1 = yu1
61-
yu2 = yu2
57+
_, yu1 = step_response(g, t, input=0, squeeze=True)
58+
_, yu2 = step_response(g, t, input=1, squeeze=True)
6259

6360
# linear system, so scale and sum previous results to get the
6461
# [1,-1] response
@@ -112,8 +109,8 @@ def synth(wb1, wb2):
112109

113110
def step_opposite(g, t):
114111
"""reponse to step of [-1,1]"""
115-
_, yu1 = step_response(g, t, input=0)
116-
_, yu2 = step_response(g, t, input=1)
112+
_, yu1 = step_response(g, t, input=0, squeeze=True)
113+
_, yu2 = step_response(g, t, input=1, squeeze=True)
117114
return yu1 - yu2
118115

119116

examples/secord-matlab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
# Bode plot for the system
2626
plt.figure(2)
27-
mag, phase, om = bode(sys, logspace(-2, 2), Plot=True)
27+
mag, phase, om = bode(sys, logspace(-2, 2), plot=True)
2828
plt.show(block=False)
2929

3030
# Nyquist plot for the system

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)