Vertical line for Bode plots
67 ビュー (過去 30 日間)
古いコメントを表示
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
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
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
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')
xline(h(3),.5,'r')
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Plot Customization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!