フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

I'm trying to figure out how to plot how the gain of a system (k) changes within the interval of -5 to 20 incrementing by 0.5. The code I have so far is below. I'm pretty sure I must be close. The 1 and 10 are given for the q values.

1 回表示 (過去 30 日間)
Joshua Brantley
Joshua Brantley 2014 年 9 月 3 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
figure (4)
hold on
q=[1 10 i];
for i=-5:0.5:20
end
p2=roots(q);
plot(real(p2), imag(p2), 'rx')
line([0,0], [-6,6])
line([-12,1], [0,0])
xlabel('Real Axis'), ylabel('Imaginary Axis')
title('k= -5<k<20');

回答 (1 件)

Image Analyst
Image Analyst 2014 年 9 月 3 日
Well you need to have something inside the for loop of course. Yours is empty! Do you think may lines like the q and p2 lines, and others, might go inside the loop???
  2 件のコメント
Joshua Brantley
Joshua Brantley 2014 年 9 月 3 日
Ok, I'm still confused on how to actually implement this. I changed the for loop to the following
for m=-5:0.5:20
q=[1 10 m];
p2(m)=roots(q(m));
plot(real(p2(m)), imag(p2(m)), 'rx')
end
Is this going towards the right track? When I run this one it says I can't use -5 as an index. Thank you for your help!
Image Analyst
Image Analyst 2014 年 9 月 3 日
You can't have negative indexes of an array. Just have p2 and it will put all the roots into an array called p2. Then you don't want the (m) in the plot statement either. Then you need to have "hold on" after the plot or else new plots will blow away old ones so fast you won't even see them. If you have "hold on" then it will keep all the plots on the graph.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by