A Nyquist diagram is a graphical representation used in control theory to evaluate the stability and performance of a linear time-invariant system by plotting the complex frequency response of its transfer function.
Here's a simple MATLAB code snippet to generate a Nyquist plot:
% Example of creating a Nyquist diagram in MATLAB
num = [1]; % Numerator coefficients
den = [1, 2, 1]; % Denominator coefficients
sys = tf(num, den); % Create transfer function
nyquist(sys); % Generate Nyquist plot
grid on; % Add grid for better readability
Understanding Nyquist Diagrams
What is a Nyquist Diagram?
A Nyquist diagram is a graphical representation used in control theory to describe the frequency response of a system. It plots the real and imaginary components of a system's transfer function, providing insights into the stability and responsiveness of the system.
The key advantage of a Nyquist plot is its ability to represent a complex system's behavior in a straightforward way. By visualizing the frequency response, engineers can assess how the system will behave across different frequencies—an essential component in control system design.
Key Concepts
Frequency Response
The frequency response of a system reveals how the output responds to different input frequencies. In simpler terms, it shows how the amplitude and phase of the output signal change when subjected to sinusoidal inputs of varying frequencies.
Nyquist diagrams translate these responses into a single plot where the x-axis represents the real part of the response, while the y-axis represents the imaginary part. This format allows engineers to see both the magnitude and phase relationship as the frequency passes through different ranges.
Stability Criteria
One of the most compelling aspects of Nyquist diagrams is their ability to aid in stability determination. Utilizing the Nyquist stability criterion, engineers can evaluate whether a system will remain stable when subjected to feedback. The key components of this stability analysis include gain and phase margins, which indicate how close the system is to instability.

Drawing a Nyquist Diagram in MATLAB
Getting Started with MATLAB
Before diving into creating Nyquist diagrams, it's important to familiarize yourself with the MATLAB environment. Launch MATLAB and ensure that the Control System Toolbox is installed, as it provides the essential functions needed for this analysis.
Understanding some basic commands and setup will help you navigate MATLAB effectively, allowing you to focus on creating and interpreting Nyquist plots. Primarily, you’ll be working with the `tf` (transfer function) and `nyquist` functions, which are fundamental for generating Nyquist diagrams.
Creating a Nyquist Diagram
Basic Syntax
To create a Nyquist plot, the basic syntax is:
nyquist(system)
Here, `system` can represent either a transfer function or a state-space system.
Example: Simple Case
Let’s create a simple first-order transfer function to illustrate how to generate a Nyquist diagram.
num = [1];
den = [1, 3, 10];
sys = tf(num, den);
nyquist(sys);
In this example, we define a transfer function with a numerator of `1` and a denominator represented by the polynomial `(s^2 + 3s + 10)`. Upon executing the `nyquist(sys)` command, it will generate a Nyquist plot for the specified system. This illustration gives you a visual representation of how this simple transfer function behaves across varying frequencies.
Analyzing the Nyquist Diagram
Interpreting the Plot
When you look at a Nyquist plot, you’ll notice that the x-axis represents the real part of the function, while the y-axis depicts the imaginary part. Points plotted on this diagram correspond to various frequencies.
Key elements to observe in the plot include:
- Poles and Zeros: Identifying their positions can help understand the dynamics of the system.
- Encirclements: These indicate how the plot interacts with critical points, particularly the point (-1, 0), which is crucial for stability analysis.
Stability Analysis
To analyze stability with the Nyquist plot, focus on the encirclements around the critical point of (-1, 0) in the complex plane. According to the Nyquist stability criterion, the number of counterclockwise encirclements of this point directly relates to the number of poles of the open-loop transfer function in the right-half plane.
If the Nyquist plot encircles the point (-1, 0), it indicates potential instability in the feedback system. Understanding this relationship is critical, as stability is essential for reliable system response.

Advanced Techniques
Adding Gain and Phase Margins
Understanding Margins
Gain and phase margins provide additional insight into how close a system is to instability. The gain margin indicates how much gain can be increased before the system becomes unstable, while the phase margin shows how much phase can change before instability occurs. These measures are vital for assessing system robustness.
Code Snippet for Gain and Phase Calculation
You can compute these margins in MATLAB using the following command:
[Gm, Pm] = margin(sys);
Here, `Gm` represents the gain margin, and `Pm` represents the phase margin. Calculating these values not only helps in understanding stability but also provides guidelines for controller design.
Multiple Systems Comparison
In practice, comparing multiple systems can often lead to better understanding and optimization. MATLAB allows you to overlay multiple Nyquist diagrams on the same plot, making comparison easy:
nyquist(sys1, sys2);
By visualizing different systems in a single plot, you can quickly identify which system offers desirable performance characteristics or stability margins.
Customizing the Plot
Plot Customization Techniques
To make the Nyquist diagram more comprehensible, you might want to customize aspects of the plot such as line styles or colors. Adding a grid can also be beneficial for interpretation:
nyquist(sys);
grid on;
This enhancement increases the visual clarity of the plot, enabling a more straightforward interpretation of the system's characteristics.
Adding Annotations
For technical presentations, annotating significant points on the Nyquist plot can be very effective. You can easily add text annotations like so:
text(realPoint, imagPoint, 'Annotation');
This functionality enhances the communication of key findings during discussions and presentations, making it easier for others to understand your analysis.

Common Issues and Troubleshooting
Common Errors in MATLAB Nyquist Plots
When generating Nyquist plots, users may encounter errors such as "the system is not proper" or regarding system stability. These issues typically arise if there are problems with the defined transfer functions or incorrect formatting.
Troubleshooting Tips
To effectively troubleshoot, consider checking these aspects:
- Verify the transfer function definitions for correctness.
- Ensure that the MATLAB Control System Toolbox is correctly installed.
- Pay attention to MATLAB warnings, as they often provide critical hints for resolving issues.

Real-World Applications of Nyquist Diagrams
Control Systems Engineering
The real-world applications of Nyquist diagrams are abundant in control systems engineering. They are essential for designing and analyzing feedback systems, ensuring that engineers can predict system behavior and maintain stability.
Other Domains
Beyond control systems, Nyquist diagrams are also invaluable in electronics and signal processing fields. For instance, they help in designing filters and assessing system responses, making them critical tools in various engineering disciplines.

Conclusion
In this guide, we explored the fundamental concepts, practical implementations, and advanced techniques for creating and analyzing a MATLAB Nyquist diagram. Understanding how to effectively utilize Nyquist plots can significantly enhance your capability in system analysis and design.
We encourage you to practice creating Nyquist diagrams with diverse systems and further explore MATLAB's robust functionalities. For more MATLAB tips and resources, stay tuned to our platform!

Additional Resources
Further Reading and References
For those looking to deepen their understanding, consider exploring books on control systems, academic journals on engineering methodologies, and official MATLAB documentation.
Online MATLAB Tools and Community Forums
Engage with online forums and communities focused on MATLAB to connect with experts, share experiences, and tap into a wealth of knowledge on using MATLAB for all your engineering needs.