Change ylabels on Bode plot

I want to change the ylabels on a Bode plot. As you know with the command bode there are two plots, one for magnitude and one for phase. But when you write:
ylabel('TheLabel')
Only the word "Phase" is changed to "TheLabel", but the word "Magnitude" is unchanged.
How do you write in order to change both the word "Magnitude" and the word "Phase"?

Réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 21 Juin 2015
Modifié(e) : Azzi Abdelmalek le 21 Juin 2015

1 vote

bode(tf(1,1:2)) % Example
axes=findobj('type','axes')
h_magnitude=get(axes(2),'YLabel')
h_phase=get(axes(1),'YLabel')
set(h_magnitude,'String','NewMagnitude')
set(h_phase,'String','NewPhase')

4 commentaires

Oak Lore
Oak Lore le 21 Juin 2015
Ok, your code works on it's own, but not when I try to incorporate it in my own. I wrote
s=zpk('s');
p1=1;
Hs=1/(1+s/p1);
bode(Hs, {0.1,10})
When I try to combine it with your code I get the following error message:
Error using InputOutputModel/subsref (line 43)
Subscript no. 2 is out of range.
Error in Rellpol (line 21)
bode(Hs(1,1:2)) % Example
How should I write in order to make it work together with my code? Please note that I want to be able to set the width of the x-axis manually, so that's why I wrote this in bold:
bode(Hs {0.1,10})
How should I write to do all this together?
Azzi Abdelmalek
Azzi Abdelmalek le 21 Juin 2015
This works fine with me
Oak Lore
Oak Lore le 21 Juin 2015
How do you write then? Can you post the code please?
s=zpk('s');
p1=1;
Hs=1/(1+s/p1);
bode(Hs, {0.1,10})
axes=findobj('type','axes')
h_magnitude=get(axes(2),'YLabel')
h_phase=get(axes(1),'YLabel')
set(h_magnitude,'String','NewMagnitude')
set(h_phase,'String','NewPhase')

Connectez-vous pour commenter.

Catégories

En savoir plus sur Get Started with Control System Toolbox dans Centre d'aide et File Exchange

Tags

Question posée :

le 21 Juin 2015

Commenté :

le 27 Juin 2015

Community Treasure Hunt

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

Start Hunting!

Translated by