Help on plot 3 roots for each variable and connecting them
4 views (last 30 days)
Show older comments
Franz Adam Magallanes
on 26 Jan 2021
Commented: Star Strider
on 26 Jan 2021
I'm trying to plot the roots coming out of the this code but after I Run the code, no graph shows up. I know that for each variable K_p_no, there's 3 roots because the pol variable shows up in the Workspace with 3 roots in a single cell. How can I find the roots of the equation and plot them all in the same graph? If possible, also connect them. This is for a PID controller but without the ID, if it helps in any way.
clc; clear all; close all;
n = 10;
K_p_neg_inf = -1000;
K_p_pos_inf = 1000;
K_p_no = K_p_neg_inf:n:K_p_pos_inf;
for i=1:length(K_p_no);
ChEq{i} = [K_p_no(i)*50 K_p_no(i)*100 1 K_p_no(i)*60]; %characteris eqn (K_p*50*s^2 + K_p*100*s + s^2 + K_p*60) of the T_s, set =0 to find the poles in the s-plane
pol{i} = roots(ChEq{i}); %poles on s-plane
plot(real(poles), imag(poles), 'rx')
xlabel('Real Axis (seconds^-1)');
ylabel('Imaginary Axis (seconds^-1)')
grid on
end
0 Comments
Accepted Answer
Star Strider
on 26 Jan 2021
See if this slightly edited version of your code does what you want:
n = 10;
K_p_neg_inf = -1000;
K_p_pos_inf = 1000;
K_p_no = K_p_neg_inf:n:K_p_pos_inf;
figure
hold on
for i=1:length(K_p_no);
ChEq{i} = [K_p_no(i)*50 K_p_no(i)*100 1 K_p_no(i)*60]; %characteris eqn (K_p*50*s^2 + K_p*100*s + s^2 + K_p*60) of the T_s, set =0 to find the poles in the s-plane
pol{i} = roots(ChEq{i}); %poles on s-plane
plot(real(pol{i}), imag(pol{i}), 'rx')
xlabel('Real Axis (seconds^-1)');
ylabel('Imaginary Axis (seconds^-1)')
end
hold off
grid
.
2 Comments
More Answers (0)
See Also
Categories
Find more on PID Controller Tuning 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!