Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to generate proper Root Locus Plots with Python 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?

like image 691
Semone Naidoo Avatar asked Oct 24 '25 03:10

Semone Naidoo


1 Answers

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

like image 87
Kathir Avatar answered Oct 26 '25 11:10

Kathir



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!