Vertical line for Bode plots

조회 수: 59 (최근 30일)
Nerma Caluk
Nerma Caluk 2022년 8월 12일
댓글: Nerma Caluk 2022년 8월 12일
I am using bodeplot option to plot my transfer functions, but I need to insert a vertical line, indicating a limit in x axis. I have tried command 'xline' but it does not show up. I need to insder 3 vertical lines corresponding to frequency = 26.5, 0.4141, 0.3126 (x axis).
This is part of the code for the plots, since putting all the equations and code would be too long:
% Acceleration Plots
figure (3)
opts1 = bodeoptions("cstprefs");
opts1.PhaseVisible = 'off';
opts1.FreqUnits = 'Hz';
opts1.MagUnits = 'abs';
opts1.MagScale = 'log';
opts1.YLim={[10^(0) 10^(11)]};
opts1.XLim={[10^(-4.5) 50]};
Mag=subplot(1,2,1);bodeplot(A_LPF_DU,A_LPP_DU,A_TDF_DU,A_TDP_DU,A_SP_DU,opts1); grid on;
title('Acceleration');
%xline(26.5,"--r") %this part does not work
Thank You!
  댓글 수: 2
Star Strider
Star Strider 2022년 8월 12일
It would likely be easier to get the outputs from bode and then do the plot separately. Using xline would then not be a problem. (The Control System Toolbox plotting functions are not always easy to work with, which is the reason I generally prefer this approach.)
dpb
dpb 2022년 8월 12일
I don't have the Control System Toolbox so can't play with it -- I HATE what TMW has done with these custom plots, though, hiding all the basic axes properties so one can't get to them to do other things they've not thought of. It's simply maddening...
That aside, the other choice besides drawing the plots themselves from scratch could be to retrieve Yair Altman's FEX <getundoc-get-undocumented-object-properties> which will uncover what are additional properties that are hidden by default. One would hope the XAxis numeric ruler object would become visible and then be able to use xline on it.
The other alternative is to add the second axes on top as did the venerable plotyy functions -- unfortunately, I see that they've now also removed a lot of the previous documentation that illustrated that "trick" with the introduction of yyaxis -- you're not supposed to do that any more, either, apparently.
There's no excuse, however, in making users go through such machinations to do trivial things, however. Simply rude and short-sighted behavior on TMW's part.

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

채택된 답변

Paul
Paul 2022년 8월 12일
Hi, Nerma,
xline draws the line in the current axes, which appears to be the phase axes, which aren't visible. So we can do this:
figure
opts1 = bodeoptions("cstprefs");
opts1.PhaseVisible = 'off';
opts1.FreqUnits = 'Hz';
opts1.MagUnits = 'abs';
opts1.MagScale = 'log';
%opts1.YLim={[10^(0) 10^(11)]};
%opts1.XLim={[10^(-4.5) 50]};
Using made up systems ....
[A_LPF_DU,A_LPP_DU,A_TDF_DU,A_TDP_DU,A_SP_DU] = deal(tf(1,[1 2]));
Mag=subplot(1,2,1);bodeplot(A_LPF_DU,A_LPP_DU,A_TDF_DU,A_TDP_DU,A_SP_DU,opts1); grid on;
title('Acceleration');
h = get(gcf,'Children')
h =
3×1 graphics array: ContextMenu Axes Axes
xline(h(3),.5,'r')
  댓글 수: 1
Nerma Caluk
Nerma Caluk 2022년 8월 12일
This works perfectly, thank you!

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by