Skip to content

Commit 3d57885

Browse files
committed
added various root_locus plotting examples
1 parent 66bee9d commit 3d57885

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

examples/root_locus.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python
2+
import control as ct
3+
# from control.rlocus import root_locus
4+
import numpy as np
5+
import matplotlib.pyplot as plt
6+
import sys
7+
8+
# create a transfer function
9+
gs_tf=ct.tf([1,10,5],[1,0,0])
10+
11+
kvect=np.linspace(0,1.5,1000)
12+
13+
rlist,klist=ct.root_locus(gs_tf,kvect=None,plot=True)
14+
plt.title("None")
15+
plt.show()
16+
17+
# root locus plot
18+
rlist,klist=ct.root_locus(gs_tf,kvect=kvect,plot=True)
19+
plt.title("kvect")
20+
plt.legend(loc='best')
21+
plt.show()
22+
23+
# calculate the root locus for matplotlib plot
24+
rlist,klist=ct.root_locus(gs_tf,kvect=kvect,Plot=False)
25+
26+
# matplotlib plot
27+
plt.title("matplotlib")
28+
for index in range(len(rlist[0])):
29+
plt.plot(np.real(rlist[:,index]),np.imag(rlist[:,index]))
30+
plt.show()

0 commit comments

Comments
 (0)