Effacer les filtres
Effacer les filtres

Vertical line for Bode plots

31 vues (au cours des 30 derniers jours)
Nerma Caluk
Nerma Caluk le 12 Août 2022
Commenté : Nerma Caluk le 12 Août 2022
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 commentaires
Star Strider
Star Strider le 12 Août 2022
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 le 12 Août 2022
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.

Connectez-vous pour commenter.

Réponse acceptée

Paul
Paul le 12 Août 2022
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 commentaire
Nerma Caluk
Nerma Caluk le 12 Août 2022
This works perfectly, thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by