..........................
% bode plot example
clear
close all
% make double integrator
sys1 = tf(1,[1,0,0]);
% discrete time
Ts = 0.02;
sys2 = c2d(sys1,Ts);
figure(1)
bode(sys2)
grid
opt = bodeoptions;
opt.FreqUnits = 'Hz';
opt.MagLowerLimMode = 'manual';
opt.MagLowerLim = -100;
figure(2)
bode(sys2,opt)
grid
............................
In the first plot, the scale goes from -400 dB to +100 dB. This is
because there is a zero at -1 on the discrete-time z-plane which makes
the magnitude dive at the Nyquist rate of 25 Hz. If this were an
interesting transfer function, the large range squashes any features.
In the second plot, we bound the bottom to -100 dB. That's great, but
somehow the top bound is still at +100 dB which I presume is a leftover
of the non lower limited y-axis scale. I don't want +100 dB at the top,
I want to set something like +10 dB.
How do I set upper limit on bode magnitude plot? I don't see anything
like MagLimits in the bodeoptions.
I want to do "ylim([-100,10])" on the upper subplot. I do not want to
have to "click" on the plot. As I am repeatedly making many plots, I
desired a script solution please.
--
Johan KULLSTAM <kulls...@comcast.net> sysengr
There is a YLimMode and YLim options on the bodeoptions. These properties
can be used to explicitly set the limits.
For example:
h = bodeplot(sys2);
ylims = getoptions(h,'YLim') % size of ylims for this plot will be 2x1 (mag;
phase)
ylims{1} = [-100,10];
setoptions(h,'YLimMode','manual','YLim',ylims)
-craig
"Johan Kullstam" <kulls...@comcast.net> wrote in message
news:87iqik4...@l71001225.res.ray.com...
> Hi Johan,
>
> There is a YLimMode and YLim options on the bodeoptions. These properties
> can be used to explicitly set the limits.
>
> For example:
>
> h = bodeplot(sys2);
> ylims = getoptions(h,'YLim') % size of ylims for this plot will be 2x1 (mag;
> phase)
> ylims{1} = [-100,10];
> setoptions(h,'YLimMode','manual','YLim',ylims)
That messes up the phase ylims. I suppose I can use the Ylim option to
set both magnitude and phase. And then, I can follow up with ylim to
re-correct the phase. Is this the way it's supposed to work?
% For example the following will set magnitude limits to (-100,10) and auto
set the limits for phase and ignore the values specified
opts = bodeoptions
opts.YLim = {[-100,10];[-360,0]}; %{maglimits;phaselimits}
opts.YLimMode = {'manual';'auto'}; %{maglimits mode;phaselimits mode}
h = bodeplot(sys2,opts)
% or for example the following will set magnitude limits to (-100,10) and
set phase limits to (-360,0)
opts = bodeoptions
opts.YLim = {[-100,10];[-360,0]}; %{maglimits;phaselimits}
opts.YLimMode = {'manual';'manual'};
h = bodeplot(sys2,opts)
-craig
"Johan Kullstam" <kulls...@comcast.net> wrote in message
news:87eit84...@l71001225.res.ray.com...
> Do you want to set both magnitude and phase ylims manually or want the
> magnitude ylims to be manual and the phase ylims to be auto?
>
> % For example the following will set magnitude limits to (-100,10) and auto
> set the limits for phase and ignore the values specified
> opts = bodeoptions
> opts.YLim = {[-100,10];[-360,0]}; %{maglimits;phaselimits}
> opts.YLimMode = {'manual';'auto'}; %{maglimits mode;phaselimits mode}
> h = bodeplot(sys2,opts)
That works! I didn't know that you can give a cellarray to YLim and
friends. The braces make sense; they are not just for annoyance. Now I
can fix up my MIMO bode plots too.
Thanks for the help.