Skip to content

Commit

Permalink
Merge branch 'master' into improve-docs
Browse files Browse the repository at this point in the history
Conflicts:
	control/mateqn.py
  • Loading branch information
cwrowley committed Mar 19, 2015
2 parents add59c3 + 770c4d7 commit 32668d3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
15 changes: 9 additions & 6 deletions control/freqplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,27 +126,30 @@ def bode_plot(syslist, omega=None, dB=None, Hz=None, deg=None,
omega = default_frequency_range(syslist)

# Get the magnitude and phase of the system
mag_tmp, phase_tmp, omega = sys.freqresp(omega)
mag_tmp, phase_tmp, omega_sys = sys.freqresp(omega)
mag = np.atleast_1d(np.squeeze(mag_tmp))
phase = np.atleast_1d(np.squeeze(phase_tmp))
phase = unwrap(phase)
if Hz: omega = omega/(2*sp.pi)
if Hz:
omega_plot = omega_sys/(2*sp.pi)
else:
omega_plot = omega_sys
if dB: mag = 20*sp.log10(mag)
if deg: phase = phase * 180 / sp.pi

mags.append(mag)
phases.append(phase)
omegas.append(omega)
omegas.append(omega_sys)
# Get the dimensions of the current axis, which we will divide up
#! TODO: Not current implemented; just use subplot for now

if (Plot):
# Magnitude plot
plt.subplot(211);
if dB:
plt.semilogx(omega, mag, *args, **kwargs)
plt.semilogx(omega_plot, mag, *args, **kwargs)
else:
plt.loglog(omega, mag, *args, **kwargs)
plt.loglog(omega_plot, mag, *args, **kwargs)
plt.hold(True);

# Add a grid to the plot + labeling
Expand All @@ -156,7 +159,7 @@ def bode_plot(syslist, omega=None, dB=None, Hz=None, deg=None,

# Phase plot
plt.subplot(212);
plt.semilogx(omega, phase, *args, **kwargs)
plt.semilogx(omega_plot, phase, *args, **kwargs)
plt.hold(True);

# Add a grid to the plot + labeling
Expand Down
24 changes: 13 additions & 11 deletions control/mateqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,25 +411,27 @@ def dlyap(A,Q,C=None,E=None):
#### Riccati equation solvers care and dare

def care(A,B,Q,R=None,S=None,E=None):
""" (X,L,G) = care(A,B,Q) solves the continuous-time algebraic Riccati
""" (X,L,G) = care(A,B,Q,R=None) solves the continuous-time algebraic Riccati
equation
:math:`A^T X + X A - X B B^T X + Q = 0`
:math:`A^T X + X A - X B R^{-1} B^T X + Q = 0`
where A and Q are square matrices of the same dimension. Further, Q
is a symmetric matrix. The function returns the solution X, the gain
matrix G = B^T X and the closed loop eigenvalues L, i.e., the eigenvalues
of A - B G.
where A and Q are square matrices of the same dimension. Further,
Q and R are a symmetric matrices. If R is None, it is set to the
identity matrix. The function returns the solution X, the gain
matrix G = B^T X and the closed loop eigenvalues L, i.e., the
eigenvalues of A - B G.
(X,L,G) = care(A,B,Q,R,S,E) solves the generalized continuous-time
algebraic Riccati equation
:math:`A^T X E + E^T X A - (E^T X B + S) R^{-1} (B^T X E + S^T) + Q = 0`
where A, Q and E are square matrices of the same dimension. Further, Q and
R are symmetric matrices. The function returns the solution X, the gain
matrix G = R^-1 (B^T X E + S^T) and the closed loop eigenvalues L, i.e.,
the eigenvalues of A - B G , E. """
where A, Q and E are square matrices of the same
dimension. Further, Q and R are symmetric matrices. If R is None,
it is set to the identity matrix. The function returns the
solution X, the gain matrix G = R^-1 (B^T X E + S^T) and the
closed loop eigenvalues L, i.e., the eigenvalues of A - B G , E."""

# Make sure we can import required slycot routine
try:
Expand Down Expand Up @@ -531,7 +533,7 @@ def care(A,B,Q,R=None,S=None,E=None):
e.info = ve.info
elif ve.info == 1:
e = ValueError("The matrix A is (numerically) singular in \
discrete-time case.")
continuous-time case.")
e.info = ve.info
elif ve.info == 2:
e = ValueError("The Hamiltonian or symplectic matrix H cannot \
Expand Down

0 comments on commit 32668d3

Please sign in to comment.