Help on plot 3 roots for each variable and connecting them

조회 수: 4 (최근 30일)
Franz Adam Magallanes
Franz Adam Magallanes 2021년 1월 26일
댓글: Star Strider 2021년 1월 26일
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

채택된 답변

Star Strider
Star Strider 2021년 1월 26일
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
Franz Adam Magallanes
Franz Adam Magallanes 2021년 1월 26일
It is what I'm looking for code-wise. The values are resulted are really really close to each other which makes the graph look like it only plotted one. The equation provided by my professor was incorrect.
Thanks for the coding help!
Star Strider
Star Strider 2021년 1월 26일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 PID Controller Tuning에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by