0
votes

I also have a problem to solve in the field of "systems theory". I solved the mathematical part, but now I have to find a virtual method for analyzing the stability of the system characterized by the transfer function. Therefore, I chose matlab.

I need to graphically display the Nyquist diagram and the poles and zeros of the transfer function.

Transfer function:

enter image description here

The code for the Nyquist diagram is as follows:

num=[1 1]
den=[1 1 4 1 2]
G=tf(num,den)
plot(nyquist(G))
grid on

The code for representing the poles and zeros of the transfer function is as follows:

num=[1 1]
den=[1 1 4 1 2]
G=tf(num,den)
plot(pzmap(G))
grid on

How could I see on the same graph both functions or one below the other?

Thank you in advance

1
Hi! Did you do any research yourself on the internet? This is namely a pretty common thing to do with matlab. You can plot two lines in the in the same figure using the hold on functionality. Plotting figures below each other can be done using subplotNathan
Of course, but it's not what I want...AlexSD
"How could I see on the same graph both functions or one below the other?" Suggests you want a figure with two lines/plots plotted in either one or two subfigures. Maybe you can clarify further what you are looking forNathan

1 Answers

1
votes

Okay, now I think I know what you want. As feedback, could you next time include in the description that nyquist() and pzmap create their own figure. That's why it was not clear what the problem was.

Anyway from the nyquist() and pzmap() function you can obtain the necessary info in order to plot it in a different graph as stated in their respective documentations (nyquist, pzmap). For w I selected a vector so that the whole nyquist shape is sufficiently visible.

num=[1 1];
den=[1 1 4 1 2];
G=tf(num,den);
w = linspace(-2*pi,2*pi,1e4);
[re,im] = nyquist(G,w);
[p,z] =pzmap(G);

figure();
plot(squeeze(re),squeeze(im));
hold on;
plot(real(p),imag(p),'*',real(z),imag(z),'o');
grid on

Resulting figure:

enter image description here