3

I am trying to generate root locus plots via Python 3, but the graphs that Python produces don't seem to be complete.

Here is the system to be implemented for the Root Locus;

enter image description here

Here is my code for the Root Locus plot;

import numpy as np
from matplotlib import pyplot as plt 
import control

%matplotlib

G = control.TransferFunction((1, 1.5), (1, 11, 10, 0))

rlist, klist = control.rlocus(G)

plt.show()

And here is the graph I get;

enter image description here

But from the textbook I'm using, this is the plot that they have;

enter image description here

Is there a way to get Python to provide a plot which is closer the actual solution, or is this the best approximation possible with Python right now?

Semone Naidoo
  • 71
  • 1
  • 7

1 Answers1

6

Try this,

import numpy as np
from matplotlib import pyplot as plt 
import control

G = control.TransferFunction((1, 1.5), (1, 11, 10, 0))

rlist, klist = control.rlocus(G, kvect=np.linspace(100.0, -100.0, num=1000))

plt.show()

Output: enter image description here

You can choose a more optimal kvect range depending on your transfer function.

kvect (list or ndarray, optional) – List of gains to use in computing diagram

Source: control.root_locus Documentation

Kathir
  • 1,282
  • 1
  • 15
  • 19