필터 지우기
필터 지우기

Change just the ylims of the Magnitude plot from the bode TF

조회 수: 11 (최근 30일)
monkey_matlab
monkey_matlab 2016년 1월 19일
댓글: Leslie Lamontagne 2023년 4월 5일
Hello,
I am trying to change the ylims of just the magnitude of the bode TF plot but I get the error "Undefined function 'getoptions' for input arguments of type 'tf'. Can you help me change the ylims of just the magnitude response? Thanks. Here is what I have so far:
w=100;
e=0.3;
lgspA = logspace(0,5,1000);
num=[2*w*e (w^2)];
den=[1 2*w*e (w^2)];
test_sys1=1-tf(num,den);
[MAG,PHASE,W] = bode(test_sys1, lgspA);
W1 = W;
MAG1 = 20*log10(squeeze(MAG));
e=0.5;
num=[2*w*e (w^2)];
den=[1 2*w*e (w^2)];
test_sys2=1-tf(num,den);
[MAG,PHASE,W] = bode(test_sys2, lgspA);
W2 = W;
MAG2 = 20*log10(squeeze(MAG));
bode(test_sys1,test_sys2);
ylims = getoptions(test_sys1,'YLim'); % size of ylims for this plot will be 2x1 (mag; phase);
ylims{1} = [-60,10];
setoptions(test_sys1,'YLimMode','manual','YLim',ylims)
legend('e=0.3','e=0.5');

채택된 답변

Star Strider
Star Strider 2016년 1월 19일
Use the bodeplot function instead of bode. It will allow you to use the setoptions function.

추가 답변 (1개)

Martin Hartenberger
Martin Hartenberger 2021년 9월 7일
편집: Martin Hartenberger 2021년 9월 7일
You have to first search for all the axes objects in the figure. The third one is the axis of the magnitude plot. After setting this axis as your current one, you can edit the axis limits with ylim and xlim:
G = tf(1,[1,0]);
f1 = bode(G);
axes_handles = findall(f1, 'type', 'axes');
axes(axes_handles(3))
ylim([-60,5])
  댓글 수: 1
Leslie Lamontagne
Leslie Lamontagne 2023년 4월 5일
This method also works when using the margin function to plot bode. Thanks!

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

카테고리

Help CenterFile Exchange에서 Plot Customization에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by