Skip to content
Merged
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
37 changes: 37 additions & 0 deletions examples/check-controllability-and-observability.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
""" check-controllability-and-observability.py

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

from __future__ import print_function

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)
28 changes: 0 additions & 28 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.")
29 changes: 0 additions & 29 deletions examples/test-statefbk.py

This file was deleted.