필터 지우기
필터 지우기

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일)
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