Skip to content

Commit 0df099f

Browse files
committed
Replaced np.matrix with np.array objects
1 parent 51a772b commit 0df099f

3 files changed

Lines changed: 27 additions & 20 deletions

File tree

examples/check-controllability-and-observability.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@
66

77
from __future__ import print_function
88

9-
from scipy import * # Load the scipy functions
9+
import numpy as np # Load the scipy functions
1010
from control.matlab import * # Load the controls systems library
1111

1212
# Parameters defining the system
1313

1414
m = 250.0 # system mass
15-
k = 40.0 # spring constant
16-
b = 60.0 # damping constant
15+
k = 40.0 # spring constant
16+
b = 60.0 # damping constant
1717

1818
# System matrices
19-
A = matrix([[1, -1, 1.],
20-
[1, -k/m, -b/m],
21-
[1, 1, 1]])
19+
A = np.array([[1, -1, 1.],
20+
[1, -k/m, -b/m],
21+
[1, 1, 1]])
2222

23-
B = matrix([[0],
24-
[1/m],
25-
[1]])
23+
B = np.array([[0],
24+
[1/m],
25+
[1]])
2626

27-
C = matrix([[1., 0, 1.]])
27+
C = np.array([[1., 0, 1.]])
2828

2929
sys = ss(A, B, C, 0)
3030

examples/rss-balred.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,20 @@
1212

1313
# controllable canonical realization computed in Matlab for the transfer function:
1414
# num = [1 11 45 32], den = [1 15 60 200 60]
15-
A = np.matrix('-15., -7.5, -6.25, -1.875; \
16-
8., 0., 0., 0.; \
17-
0., 4., 0., 0.; \
18-
0., 0., 1., 0.')
19-
B = np.matrix('2.; 0.; 0.; 0.')
20-
C = np.matrix('0.5, 0.6875, 0.7031, 0.5')
21-
D = np.matrix('0.')
15+
A = np.array([
16+
[-15., -7.5, -6.25, -1.875],
17+
[8., 0., 0., 0.],
18+
[0., 4., 0., 0.],
19+
[0., 0., 1., 0.]
20+
])
21+
B = np.array([
22+
[2.],
23+
[0.],
24+
[0.],
25+
[0.]
26+
])
27+
C = np.array([[0.5, 0.6875, 0.7031, 0.5]])
28+
D = np.array([[0.]])
2229

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

examples/slycot-import-test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
b = 60.0 # damping constant
1515

1616
# System matrices
17-
A = np.matrix([[1, -1, 1.], [1, -k/m, -b/m], [1, 1, 1]])
18-
B = np.matrix([[0], [1/m], [1]])
19-
C = np.matrix([[1., 0, 1.]])
17+
A = np.array([[1, -1, 1.], [1, -k/m, -b/m], [1, 1, 1]])
18+
B = np.array([[0], [1/m], [1]])
19+
C = np.array([[1., 0, 1.]])
2020
sys = ss(A, B, C, 0)
2121

2222
# Python control may be used without slycot, for example for a pole placement.

0 commit comments

Comments
 (0)