How to Plot Root Locus in MATLAB
This tutorial will discuss calculating and plotting the root locus of a dynamic system using the rlocus()
function in Matlab.
Calculate and Plot the Root Locus of Dynamic System Using the rlocus()
Function in MATLAB
We use root locus to check the effect of feedback gain variation on closed-loop pole locations, and these locations provide information about the time and frequency response.
The rlocus()
function calculates and plots the root locus of a given system. It provides the closed-loop pole trajectories of the given function, a function of feedback gain. We have to pass the system’s transfer function inside the rlocus()
function to plot the root locus of that function.
For example, let’s create a system’s transfer function using the tf()
function and plot its root locus using the rlocus()
function in Matlab. See the code below.
sys = tf([2 5 1],[1 2 3]);
rlocus(sys)
Output:
The x
symbol donates the poles in the output, and the o
symbol donates the zeros of the system’s transfer function.
We can also plot multiple root locus of multiple systems using the rlocus()
function. If we pass transfer functions of multiple systems in the rlocus()
function, it will plot the root locus of all the systems on the same plot with different colors.
We can use the legend()
function to give the name to each plot to identify them easily. For example, let’s plot the root locus of two systems and add the legend using the legend()
function.
See the code below.
sys1 = tf([2 5 1],[1 2 3]);
sys2 = tf([2 2 1],[1 2]);
rlocus(sys1,sys2)
legend('sys1','sys2')
Output:
We can also find the values of closed-loop poles locations and feedback gain using the rlocus()
function. For example, let’s find the closed-loop poles locations and feedback gain values of the above system. See the code below.
sys = tf([2 5 1],[1 2 3]);
[R,K] = rlocus(sys)
size(R)
Output:
ans =
2 55
In the output, you can see that the size of the variable R
- 2-by-55.