Categories

# Nyquist Matlab

In this article, we will learn how to create a Nyquist plot in MATLAB. Nyquist plots find their utility in analyzing system properties, like phase margin, gain margin & stability. As we will move forward in the article, we will learn how to create simple Nyquist plots and also Nyquist plots with complex conditions.

## Understanding of Nyquist Plot

Nyquist plots also known as Nyquist Diagrams are used in signal processing and control engineering for plotting frequencies. Nyquist diagrams are used commonly to assess the stability of systems and also to get feedback. Cartesian coordinates are used for Nyquist plots. On X-axis, we plot the real part of our transfer function and on Y-axis, we plot the imaginary part. To get a frequency plot, it is passed as a parameter and this results in a graph based on the frequency. Polar coordinates can also be used for Nyquist plots. Here, radical coordinates are used to represent the transfer function’s gain, and the corresponding angular coordinate is represented by the transfer function’s phase.

## Syntax for Creating a Nyquist Plot in Matlab

``nyquist(sys)``

Nyquist  function in MATLAB helps us in creating a Nyquist plot, related to frequency response produced by a dynamic model.

Let us understand this clearly with the help of a few examples:

To draw a Nyquist plot, we will first create a transfer function as follows:

``H = 70 / (s+5) (s+ 4)``

Now, this is a simple example without any other condition.

We can write above system as:

``H = 70 / (s^2 + 9s + 20)``

This transfer function is then passed as an argument to our function ‘nyquist’
i.enyquist(H)

This is how our input and output will look like in MATLAB console:

## Input:

``````H=tf([0 0 70],[1 9 20]);
nyquist(H)``````

## Output:

In the next example, we will see a Nyquist plot with a pole at the center/origin.

Here is our transfer function:

``H = 40 / s^3 + 2s ^ 2 + 3s + 4``

This transfer function is then passed as an argument to our function ‘nyquist’
i.enyquist(H)

This is how our input and output will look like in MATLAB console:

## Input:

``````H=tf([40],[3 2 3 4]);
nyquist(H)``````

## Output:

The system represented by our transfer function is having a pole located at the origin. This signifies the requirement of the detour around this pole. This is not shown on the plot created by Matlab.  In a system like this where a detour is required around the pole, we must understand the result of the detour.  In our case, since we have a single-pole located at origin & the detour has its radius approaching ‘0’&moving in the counter-clockwise direction, we interpret that the missing part of the plot that MATLAB does not show is a semicircle. This semicircle lies at infinity and in the clockwise direction.

Let’s take another example with a different condition:

In this example, we will see a Nyquist plot with a double pole at the center/origin.

Here is our transfer function:

``H = 5s + 20 / s^3 + 5s^2``

This transfer function is then passed as an argument to our function ‘nyquist’
i.enyquist(H)

This is how our input and output will look like in MATLAB console:

## Input:

``````H=tf([5 20],[1 5 0 0]);
nyquist(H)``````

## Output:

As we can see from the plot obtained, the 2 branches are going off towards infinity.  Also, as we have a double pole at the origin, it can be inferred that a counter-clockwise detour of 180° around the origin is yielding a clock-wise detour of 360°.

Finally, let’s take an example where transfer function will have one pole in RHP and the pole will be stable:

Here is our transfer function:

``H = 20s + 40 / s^2 - 8``

This transfer function is then passed as an argument to our function ‘nyquist’
i.enyquist(H)

This is how our input and output will look like in MATLAB console:

## Input:

``````H=tf([20 40],[ 1 0 -8]);
nyquist(H)``````

## Output:

So, in this article, we learned how to create a Nyquist plot in MATLAB. We can create both stable and unstable plots in MATLAB. As an additional tip, please keep in mind that to display the real & imaginary part of our given frequency, we can activate the data markers in MATLAB. For this, we just need to click at any point on the curve.