Skip to content

Commit 701e83e

Browse files
committed
* Made fixes to documentation (intro, matlab)
* Got rid of unit test error in hsvd (convert slycot args to numpy array) * Tracked down possible errors in convert_test (still in progress) See ChangeLog for more detailed list of code that was modified
1 parent c6652ee commit 701e83e

File tree

7 files changed

+299
-34
lines changed

7 files changed

+299
-34
lines changed

ChangeLog

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
2011-06-25 Richard Murray <murray@malabar.local>
2+
3+
* src/xferfcn.py (TransferFunction._common_den): changed tolerance
4+
for detecting complex valued poles to a user-settable parameter,
5+
with default value 1e-8. This was an attempt to fix errors in the
6+
convert_test.py unittest script (conversion routine was
7+
misclassifying some poles as imaginary when they weren't).
8+
9+
* src/xferfcn.py (_convertToTransferFunction): converted arguments
10+
to tb04ad to numpy arrays; fixes a unit test error in convert_test.py.
11+
12+
* src/statefbk.py (gram): convert system matrix passed to sb03md to
13+
numpy array; this fixes a unit test error in modelsimp_test.py.
14+
15+
* src/matlab.py (impulse): got rid of X0 argument for impulse
16+
response (not implemented in MATLAB).
17+
18+
* doc/intro.rst: added some quick start information
19+
20+
* src/matlab.py: added documentation for step, impulse, initial, lsim
21+
22+
* src/timeresp.py: fixed some MATLAB specific function names in
23+
function doc strings
24+
125
2011-06-22 Richard Murray <murray@malabar.local>
226

327
* doc/intro.rst: fixed some small types

doc/intro.rst

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ The python-control package is a set of python classes and functions
88
that implement common operations for the analysis and design of
99
feedback control systems. The initial goal is to implement all of the
1010
functionality required to work through the examples in the textbook
11-
Feedback Systems by Åström and Murray. A MATLAB compatibility package
12-
(control.matlab) is available that provides functions corresponding to
13-
the commands available in the MATLAB Control Systems Toolbox.
11+
Feedback Systems by Astrom and Murray. A MATLAB compatibility package
12+
(control.matlab) is available that provides many of the common
13+
functions corresponding to commands available in the MATLAB Control
14+
Systems Toolbox.
1415

1516
In addition to the documentation here, there is a project wiki that
1617
contains some additional information about how to use the package
@@ -26,3 +27,19 @@ Some Differences from MATLAB
2627
* Transfer functions are only implemented for SISO systems (due to
2728
limitations in the underlying signals.lti class); use state space
2829
representations for MIMO systems.
30+
31+
Getting Started
32+
---------------
33+
1. Download the latest release from http:sf.net/projects/python-control/files.
34+
2. Untar the source code in a temporary directory and run 'python setup.py
35+
install' to build and install the code
36+
3. To see if things are working correctly, run ipython -pylab and run the
37+
script 'examples/secord-matlab.py'. This should generate a set response,
38+
Bode plot and Nyquist plot for a simple second order system.
39+
4. To see the commands that are available, run the following commands in
40+
ipython::
41+
>>> import control
42+
>>> ?control.matlab
43+
5. If you want to have a MATLAB-like environment for running the control
44+
toolbox, use::
45+
>>> from control.matlab import *

src/matlab.py

Lines changed: 198 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,21 +1128,217 @@ def dcgain(*args):
11281128
# Call corresponding functions in timeresp, with arguments transposed
11291129

11301130
def step(sys, T=None, X0=0., input=0, output=0, **keywords):
1131+
'''
1132+
Step response of a linear system
1133+
1134+
If the system has multiple inputs or outputs (MIMO), one input and one
1135+
output have to be selected for the simulation. The parameters `input`
1136+
and `output` do this. All other inputs are set to 0, all other outputs
1137+
are ignored.
1138+
1139+
Parameters
1140+
----------
1141+
sys: StateSpace, or TransferFunction
1142+
LTI system to simulate
1143+
1144+
T: array-like object, optional
1145+
Time vector (argument is autocomputed if not given)
1146+
1147+
X0: array-like or number, optional
1148+
Initial condition (default = 0)
1149+
1150+
Numbers are converted to constant arrays with the correct shape.
1151+
1152+
input: int
1153+
Index of the input that will be used in this simulation.
1154+
1155+
output: int
1156+
Index of the output that will be used in this simulation.
1157+
1158+
**keywords:
1159+
Additional keyword arguments control the solution algorithm for the
1160+
differential equations. These arguments are passed on to the function
1161+
:func:`control.ForcedResponse`, which in turn passes them on to
1162+
:func:`scipy.integrate.odeint`. See the documentation for
1163+
:func:`scipy.integrate.odeint` for information about these
1164+
arguments.
1165+
1166+
Returns
1167+
-------
1168+
T: array
1169+
Time values of the output
1170+
1171+
yout: array
1172+
Response of the system
1173+
1174+
See Also
1175+
--------
1176+
lsim, initial, impulse
1177+
1178+
Examples
1179+
--------
1180+
>>> T, yout = step(sys, T, X0)
1181+
'''
11311182
T, yout = timeresp.StepResponse(sys, T, X0, input, output,
11321183
transpose = True, **keywords)
11331184
return T, yout
11341185

1135-
def impulse(sys, T=None, X0=0., input=0, output=0, **keywords):
1136-
T, yout = timeresp.ImpulseResponse(sys, T, X0, input, output,
1186+
def impulse(sys, T=None, input=0, output=0, **keywords):
1187+
'''
1188+
Impulse response of a linear system
1189+
1190+
If the system has multiple inputs or outputs (MIMO), one input and
1191+
one output must be selected for the simulation. The parameters
1192+
`input` and `output` do this. All other inputs are set to 0, all
1193+
other outputs are ignored.
1194+
1195+
Parameters
1196+
----------
1197+
sys: StateSpace, TransferFunction
1198+
LTI system to simulate
1199+
1200+
T: array-like object, optional
1201+
Time vector (argument is autocomputed if not given)
1202+
1203+
input: int
1204+
Index of the input that will be used in this simulation.
1205+
1206+
output: int
1207+
Index of the output that will be used in this simulation.
1208+
1209+
**keywords:
1210+
Additional keyword arguments control the solution algorithm for the
1211+
differential equations. These arguments are passed on to the function
1212+
:func:`lsim`, which in turn passes them on to
1213+
:func:`scipy.integrate.odeint`. See the documentation for
1214+
:func:`scipy.integrate.odeint` for information about these
1215+
arguments.
1216+
1217+
Returns
1218+
-------
1219+
T: array
1220+
Time values of the output
1221+
yout: array
1222+
Response of the system
1223+
1224+
See Also
1225+
--------
1226+
lsim, step, initial
1227+
1228+
Examples
1229+
--------
1230+
>>> T, yout = impulse(sys, T)
1231+
'''
1232+
T, yout = timeresp.ImpulseResponse(sys, T, 0, input, output,
11371233
transpose = True, **keywords)
11381234
return T, yout
11391235

11401236
def initial(sys, T=None, X0=0., input=0, output=0, **keywords):
1237+
'''
1238+
Initial condition response of a linear system
1239+
1240+
If the system has multiple inputs or outputs (MIMO), one input and one
1241+
output have to be selected for the simulation. The parameters `input`
1242+
and `output` do this. All other inputs are set to 0, all other outputs
1243+
are ignored.
1244+
1245+
Parameters
1246+
----------
1247+
sys: StateSpace, or TransferFunction
1248+
LTI system to simulate
1249+
1250+
T: array-like object, optional
1251+
Time vector (argument is autocomputed if not given)
1252+
1253+
X0: array-like object or number, optional
1254+
Initial condition (default = 0)
1255+
1256+
Numbers are converted to constant arrays with the correct shape.
1257+
1258+
input: int
1259+
Index of the input that will be used in this simulation.
1260+
1261+
output: int
1262+
Index of the output that will be used in this simulation.
1263+
1264+
**keywords:
1265+
Additional keyword arguments control the solution algorithm for the
1266+
differential equations. These arguments are passed on to the function
1267+
:func:`lsim`, which in turn passes them on to
1268+
:func:`scipy.integrate.odeint`. See the documentation for
1269+
:func:`scipy.integrate.odeint` for information about these
1270+
arguments.
1271+
1272+
1273+
Returns
1274+
-------
1275+
T: array
1276+
Time values of the output
1277+
yout: array
1278+
Response of the system
1279+
1280+
See Also
1281+
--------
1282+
lsim, step, impulse
1283+
1284+
Examples
1285+
--------
1286+
>>> T, yout = initial(sys, T, X0)
1287+
'''
11411288
T, yout = timeresp.InitialResponse(sys, T, X0, input, output,
11421289
transpose = True, **keywords)
11431290
return T, yout
11441291

11451292
def lsim(sys, U=0., T=None, X0=0., **keywords):
1293+
'''
1294+
Simulate the output of a linear system.
1295+
1296+
As a convenience for parameters `U`, `X0`:
1297+
Numbers (scalars) are converted to constant arrays with the correct shape.
1298+
The correct shape is inferred from arguments `sys` and `T`.
1299+
1300+
Parameters
1301+
----------
1302+
sys: Lti (StateSpace, or TransferFunction)
1303+
LTI system to simulate
1304+
1305+
U: array-like or number, optional
1306+
Input array giving input at each time `T` (default = 0).
1307+
1308+
If `U` is ``None`` or ``0``, a special algorithm is used. This special
1309+
algorithm is faster than the general algorithm, which is used otherwise.
1310+
1311+
T: array-like
1312+
Time steps at which the input is defined, numbers must be (strictly
1313+
monotonic) increasing.
1314+
1315+
X0: array-like or number, optional
1316+
Initial condition (default = 0).
1317+
1318+
**keywords:
1319+
Additional keyword arguments control the solution algorithm for the
1320+
differential equations. These arguments are passed on to the function
1321+
:func:`scipy.integrate.odeint`. See the documentation for
1322+
:func:`scipy.integrate.odeint` for information about these
1323+
arguments.
1324+
1325+
Returns
1326+
-------
1327+
T: array
1328+
Time values of the output.
1329+
yout: array
1330+
Response of the system.
1331+
xout: array
1332+
Time evolution of the state vector.
1333+
1334+
See Also
1335+
--------
1336+
step, initial, impulse
1337+
1338+
Examples
1339+
--------
1340+
>>> T, yout, xout = lsim(sys, U, T, X0)
1341+
'''
11461342
T, yout, xout = timeresp.ForcedResponse(sys, T, U, X0,
11471343
transpose = True, **keywords)
11481344
return T, yout, xout

src/statefbk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def gram(sys,type):
328328
raise ControlSlycot("can't find slycot module 'sb03md'")
329329
n = sys.states
330330
U = np.zeros((n,n))
331-
A = sys.A
331+
A = np.array(sys.A) # convert to NumPy array for slycot
332332
X,scale,sep,ferr,w = sb03md(n, C, A, U, dico, job='X', fact='N', trana=tra)
333333
gram = X
334334
return gram

src/timeresp.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -419,11 +419,11 @@ def StepResponse(sys, T=None, X0=0., input=0, output=0, \
419419
420420
See Also
421421
--------
422-
lsim, initial, impulse
422+
ForcedResponse, InitialResponse, ImpulseResponse
423423
424424
Examples
425425
--------
426-
>>> T, yout = step(sys, T, X0)
426+
>>> T, yout = StepResponse(sys, T, X0)
427427
"""
428428
sys = _convertToStateSpace(sys)
429429
sys = _mimo2siso(sys, input, output, warn_conversion=True)
@@ -491,11 +491,11 @@ def InitialResponse(sys, T=None, X0=0., input=0, output=0, transpose=False,
491491
492492
See Also
493493
--------
494-
lsim, step, impulse
494+
ForcedResponse, ImpulseResponse, StepResponse
495495
496496
Examples
497497
--------
498-
>>> T, yout = InitialResponsesys, T, X0)
498+
>>> T, yout = InitialResponse(sys, T, X0)
499499
"""
500500
sys = _convertToStateSpace(sys)
501501
sys = _mimo2siso(sys, input, output, warn_conversion=True)
@@ -564,7 +564,7 @@ def ImpulseResponse(sys, T=None, X0=0., input=0, output=0,
564564
565565
See Also
566566
--------
567-
lsim, step, initial
567+
ForcedReponse, InitialResponse, StepResponse
568568
569569
Examples
570570
--------

0 commit comments

Comments
 (0)