필터 지우기
필터 지우기

Hold on not working for plotting transfer function MATLAB

조회 수: 1 (최근 30일)
Sebastian Remar
Sebastian Remar 2020년 6월 11일
댓글: Star Strider 2020년 6월 11일
%% DATA
k1 = (1.5+0)/2; % Should be unstable
k2 = 1.5; % Should be marginally stable
k3 = (1.5+2.5)/2; % Should be stable
k4 = 2.5; % Should be stable
k5 = (57.5+2.5)/2; % Should be stable
k6 = 57.5; % Should be stable
k7 = 1000; % Should be stable
x = [k1,k2,k3,k4,k5,k6,k7];
% Vector of ks
t = 0:.01:5;
steps = ones(1,length(t)); % Input - step
t_f = tf([1 18] , [1 6 -27]);
color = ['g','b','r','y','m','k','c']; % color of plots
m=1;
hold on
for i = 1:length(x)
t_f = tf(x(i)*[1 18] , [1 6+x(i) -27+18*x(i)]);
result(i) = t_f;
y = lsim(result(i),steps,t);
% figure(i) When I use this method it actually plots the transfer functions
plot(t,y,color(:,m),'linewidth',1.5) % Plot w/ different colors
m = m + 1; % var to change color
end
legend({'k1','k2','k3','k4','k5','k6','k7'},'Location','NorthWest')
hold off
I don't understand why it doesn't plot the rest of my x matrix. It plots the first value, x(1), then it just gives me lines = 0 of different colors. When I use figure(i), it works, but that's not what I need right now. Any suggestions? thanks
  댓글 수: 2
Anish Walia
Anish Walia 2020년 6월 11일
can you provide the variable x?
Sebastian Remar
Sebastian Remar 2020년 6월 11일
Yes, I edited the first code. The x vector is now there

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

채택된 답변

Star Strider
Star Strider 2020년 6월 11일
All the curves are plotted, however some overplot others given the limited resolution.
Change the plot call to:
plot(t(y>1E-4),y(y>1E-4),color(:,m),'linewidth',1.5) % Plot w/ different colors
set(gca, 'YScale','log')
to see them, although some are barely visible. (For some reason that I did not explore, semilogy does not work here.)
  댓글 수: 2
Sebastian Remar
Sebastian Remar 2020년 6월 11일
Thank you, that makes a lot of sense.
Star Strider
Star Strider 2020년 6월 11일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by