Bode plot phase grid alpha

13 views (last 30 days)
Marko
Marko on 15 Aug 2016
Commented: Star Strider on 15 Aug 2016
Hello,
I'd like to decrease transparency of grid lines in magnitude and phase plot in bode plot. I managed to do it for magnitude plow with command:
ax1 = gca;
ax1.GridAlpha = 0.5;
ax1.MinorGridAlpha = 0.5;
But it doesn't work for phase plot. Is there a way to do it for both? Thanks

Answers (1)

Star Strider
Star Strider on 15 Aug 2016
The bode and bodeplot functions don’t act like normal subplots, so that may not be possible.
There is a work-around if you have the Signal Processing Toolbox. Use the freqs (or for discrete systems, freqz) function. You cannot use your Control Systems Toolbox ‘system’ objects, so you have to use the transfer function, but that’s a minor inconvenience if the plot format is important.
This works:
b = [0.1 0.2 0.3]; % Create Transfer Function
a = [0.1 0.9 0.2]; % Create Transfer Function
figure(1)
freqs(b,a);
ax1 = subplot(2,1,1);
ax1.GridAlpha = 0.5;
ax1.MinorGridAlpha = 0.5;
ax2 = subplot(2,1,2);
ax2.GridAlpha = 0.5;
ax2.MinorGridAlpha = 0.5;
  2 Comments
Star Strider
Star Strider on 15 Aug 2016
Marko’s ‘Answer’ moved here:
(15:30 UCT)
Thanks for the answer but the option with freqs is a bit clunky for me at the moment. Nevertheless, thanks for the proposition. Finally I changed LineWidth to make the grid a bit more visible when I print out the figures.
Star Strider
Star Strider on 15 Aug 2016
My pleasure.
You would have to get your transfer function from your system object, but that’s relatively easy to do:
b = [0.1 0.2 0.3]; % Create Transfer Function
a = [0.1 0.9 0.2]; % Create Transfer Function
h = tf(b,a);
hb = h.Numerator{:};
ha = h.Denominator{:};
Then plug them into freqs and everything else will work.

Sign in to comment.

Categories

Find more on Get Started with Control System Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!