close
close
how to plot root locus in matlab

how to plot root locus in matlab

3 min read 17-01-2025
how to plot root locus in matlab

Root locus plots are invaluable tools for analyzing the stability and performance of control systems. They visually represent the movement of closed-loop poles as a system gain varies. MATLAB provides a straightforward way to generate these plots, simplifying the analysis process. This guide will walk you through plotting root locus in MATLAB, covering various aspects and techniques.

Understanding the Root Locus

Before diving into the MATLAB implementation, let's briefly review the fundamental concept of a root locus. A root locus plot shows the locations of the closed-loop poles of a system as a parameter (typically the gain, K) varies from 0 to ∞. These poles directly influence the system's transient response (stability, speed of response, overshoot). The plot helps engineers understand how changing the gain impacts system stability and performance.

Plotting Root Locus in MATLAB: Basic Steps

The simplest way to generate a root locus plot in MATLAB is using the rlocus function. This function requires the system's transfer function as input. Let's illustrate with an example.

Example 1: Simple System

Consider a system with the following transfer function:

G(s) = K / (s(s+2)(s+5))

% Define the numerator and denominator polynomials
num = 1;
den = [1 7 10 0];

% Create the transfer function
sys = tf(num, den);

% Plot the root locus
rlocus(sys);

This code first defines the numerator and denominator polynomials of the transfer function. Then, it creates a transfer function object using the tf function. Finally, the rlocus function generates the root locus plot.

Interpreting the Plot:

The resulting plot shows how the closed-loop poles move as K increases. Points where branches cross the imaginary axis indicate instability. The plot reveals potential stability issues and the range of K values for stable operation.

Adding Enhancements to Your Root Locus Plot

The basic rlocus function produces a clear plot, but adding enhancements significantly improves understanding.

1. Specifying the Gain Range:

The default range for K might not always be suitable. You can control this using the rlocus(sys, K) syntax, where K is a vector of gain values.

K = logspace(-1, 2, 100);  % Gains from 0.1 to 100
rlocus(sys, K);

2. Adding Grid Lines:

Grid lines, especially the damping ratio and natural frequency lines, enhance the plot's interpretability. Use the sgrid function to overlay these lines.

sgrid;

3. Labeling and Titling:

Clear labeling significantly improves readability.

title('Root Locus Plot');
xlabel('Real Axis');
ylabel('Imaginary Axis');

4. Handling Multiple Systems:

The rlocus function can handle multiple systems simultaneously. Simply provide multiple transfer function objects as input.

sys1 = tf(num1, den1);
sys2 = tf(num2, den2);
rlocus([sys1, sys2]);

Advanced Techniques

For more complex scenarios, additional techniques are beneficial.

Using sisotool:

MATLAB's interactive sisotool provides a rich environment for root locus analysis and system design. It allows detailed investigation and manipulation of the plot.

sisotool(sys);

This opens the interactive sisotool with your system, allowing for detailed analysis and design adjustments.

Analyzing Closed-Loop Transfer Function:

Often, you'll want to investigate the closed-loop system's response. This can be achieved using the feedback function which creates the closed-loop transfer function for a given gain.

K = 10; %Example gain
closed_loop_sys = feedback(K*sys, 1);
step(closed_loop_sys); %Step response analysis

This creates the closed loop transfer function for K=10 and displays the step response which is helpful in understanding the dynamic behavior.

Conclusion

MATLAB offers powerful tools for creating and analyzing root locus plots. By understanding the basic rlocus function and incorporating enhancements like grid lines, gain range specification, and leveraging sisotool, you can effectively analyze the stability and performance of your control systems. Remember to interpret the results carefully to gain insights into your system's behavior under varying gain conditions. This comprehensive approach will make your control system analysis more efficient and insightful.

Related Posts