Skip to content

Fix python2 print in examples #266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions examples/check-controllability-and-observability.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
""" check-controllability-and-observability.py

Example to check the controllability and the observability of a state space system.
RMM, 6 Sep 2010
"""

from scipy import * # Load the scipy functions
from control.matlab import * # Load the controls systems library

# Parameters defining the system
m = 250.0 # system mass
k = 40.0 # spring constant
b = 60.0 # damping constant

# System matrices
A = matrix([[1, -1, 1.],
[1, -k / m, -b / m],
[1, 1, 1]])

B = matrix([[0],
[1 / m],
[1]])

C = matrix([[1., 0, 1.]])

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

# Check controllability
Wc = ctrb(A, B)
print("Wc = ", Wc)

# Check Observability
Wo = obsv(A, C)
print("Wo = ", Wo)
26 changes: 0 additions & 26 deletions examples/slicot-test.py

This file was deleted.

45 changes: 45 additions & 0 deletions examples/slycot-import-test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
""" slycot-import-test.py

Simple example script to test Slycot import
RMM, 28 May 09
"""

import numpy as np
from scipy import *
from control.matlab import *
from control.exception import slycot_check

# Parameters defining the system
m = 250.0 # system mass
k = 40.0 # spring constant
b = 60.0 # damping constant

# System matrices
A = np.matrix([[1, -1, 1.], [1, -k / m, -b / m], [1, 1, 1]])
B = np.matrix([[0], [1 / m], [1]])
C = np.matrix([[1., 0, 1.]])
sys = ss(A, B, C, 0)

# Python control may be used without slycot, for example for a pole placement.
# Eigenvalue placement
w = [-3, -2, -1]
K = place(A, B, w)
print("[python-control (from scipy)] K = ", K)
print("[python-control (from scipy)] eigs = ", np.linalg.eig(A - B * K)[0])

# Before using one of its routine, check that slycot is installed.
w = np.array([-3, -2, -1])
if slycot_check():
# Import routine sb01bd used for pole placement.
from slycot import sb01bd

n = 3 # Number of states
m = 1 # Number of inputs
npp = 3 # Number of placed eigen values
alpha = 1 # Maximum threshold for eigen values
dico = 'D' # Discrete system
_, _, _, _, _, K, _ = sb01bd(n, m, npp, alpha, A, B, w, dico, tol=0.0, ldwork=None)
print("[slycot] K = ", K)
print("[slycot] eigs = ", np.linalg.eig(A + np.dot(B, K))[0])
else:
print("Slycot is not installed.")
27 changes: 0 additions & 27 deletions examples/test-statefbk.py

This file was deleted.

2 changes: 1 addition & 1 deletion examples/tfvis.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def redraw(self):
tvec, yvec = control.matlab.step(self.sys)
plt.plot(tvec.T, yvec)
except:
print "Error plotting step response"
print("Error plotting step response")
plt.suptitle('Step Response')

self.canvas_pzmap.show()
Expand Down