How to colour regions in a graph: poles and zeros

2 views (last 30 days)
Hi guys! Hoping for some help if anyone here has expertise plotting a graph using complex conjugates and zeros
We've been given the task to find a region where a specific set of values are valid on the real and complex axis. I've calculated the borders(?) and was wondering if anyone would know how I could add this to my current matlab code, as Im checking what fits in the borders :)
The borders are:
-2.665 + 0i to 0±2.7996i
at an angle of 46.37 degrees from -2.665 in both directions
sorry if the wording is a little confusing.
this is the code I'd like to plot on this shading.
hold on
for kp=[2, 4, 8, 16, 32, 64]
disp(kp)
G = tf([kp 64], [1 10 16 0]);
CLTF = feedback(kp*G,1)
pzmap(CLTF)
end
If anyone could help this would be mad appreciated

Answers (1)

TED MOSBY
TED MOSBY on 9 Jul 2025
Edited: TED MOSBY on 9 Jul 2025
Hi,
You can achieve this by using the fill function in MATLAB to create the shaded region before you plot your pole-zero map. It looks like the region you've described is a triangle with vertices at (-2.665, 0), (0, 2.7996), and (0, -2.7996).
Here is how you can do that:
figure;
hold on;
x_vertices = [-2.665, 0, 0];
y_vertices = [0, 2.7996, -2.7996];
fill(x_vertices, y_vertices, 'y', 'FaceAlpha', 0.2, 'EdgeColor', 'k', 'LineStyle', '--');
for kp = [2, 4, 8, 16, 32, 64]
G = tf([kp 64], [1 10 16 0]);
CLTF = feedback(kp*G, 1);
p = pole(CLTF);
end
grid on;
xlabel('Real Axis (\sigma)');
ylabel('Imaginary Axis (j\omega)');
ax = gca;
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';
axis equal;
hold off;
Here is more information on "fill" : https://www.mathworks.com/help/matlab/ref/fill.html
Hope it helps!

Categories

Find more on Graphics in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!