Feedback control of Dynamic systems¶

6장 예제 풀이¶

EXAMPLE 6.8 Nyquist Plot for a Second-Order System¶

In [1]:
import control as ctrl
import matplotlib.pyplot as plt
import numpy as np

# Define a transfer function (example: G(s) = 1 / (s^2 + 2s + 1))
numerator = [1]
denominator = [1, 2, 1]
system = ctrl.TransferFunction(numerator, denominator)

# Create a Nyquist plot
ctrl.nyquist_plot(system, omega=np.logspace(-2, 2, 1000), plot=True)

# Customize the plot (optional)
plt.title('Nyquist Plot')
plt.xlabel('Real')
plt.ylabel('Imaginary')
plt.axhline(0, color='black', linewidth=0.5)
plt.axvline(0, color='black', linewidth=0.5)
plt.grid(True, which='both', linestyle='--', linewidth=0.5)
plt.show()
In [2]:
# root locus
# Plot the root locus
ctrl.root_locus(system, kvect=np.linspace(0, 100, 1000))

# Customize the plot (optional)
plt.title('Root Locus Plot')
plt.xlabel('Real')
plt.ylabel('Imaginary')
plt.axhline(0, color='black', linewidth=0.5)
plt.axvline(0, color='black', linewidth=0.5)
plt.grid(True, linestyle='--', linewidth=0.5)
# Set specific x and y limits to zoom in
plt.xlim([-5, 1])  # Adjust as needed
plt.ylim([-20, 20])  # Adjust as needed
plt.show()

EXAMPLE 6.9 Nyquist Plot for a Third-Order System¶

In [3]:
# Define a transfer function (example: G(s) = 1 / (s^3 + 2s^2 + s))
numerator = [1]
denominator = [1, 2, 1, 0]
system = ctrl.TransferFunction(numerator, denominator)
print("system is {}".format(system))
# Create a Nyquist plot
ctrl.nyquist_plot(system, omega=np.logspace(-5, 5, 1000), plot=True)

# Customize the plot (optional)
plt.title('Nyquist Plot')
plt.xlabel('Real')
plt.ylabel('Imaginary')
plt.axhline(0, color='black', linewidth=0.5)
plt.axvline(0, color='black', linewidth=0.5)
plt.grid(True, which='both', linestyle='--', linewidth=0.5)
plt.show()
system is 
       1
---------------
s^3 + 2 s^2 + s

In [4]:
# root locus
# Plot the root locus
ctrl.root_locus(system, kvect=np.linspace(0, 100, 1000))

# Customize the plot (optional)
plt.title('Root Locus Plot')
plt.xlabel('Real')
plt.ylabel('Imaginary')
plt.axhline(0, color='black', linewidth=0.5)
plt.axvline(0, color='black', linewidth=0.5)
plt.grid(True, linestyle='--', linewidth=0.5)
# Set specific x and y limits to zoom in
plt.xlim([-5, 5])  # Adjust as needed
plt.ylim([-5, 5])  # Adjust as needed
plt.show()