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 Center および File ExchangePID Controller Tuning についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by