MATLAB Answers

Fill background area between two x values in a graph

144 views (last 30 days)
leonidas86
leonidas86 on 7 Jun 2018
Edited: Aquatris on 21 Nov 2020
Hello,
How can I fill a specified background area between two x values?

Answers (1)

Aquatris
Aquatris on 8 Jun 2018
A simple and quick way is to fill a rectangle before you start your plot.
x1 = 0.4; x2 = 0.9;
y1 = 1; y2 = -1;
figure(1)
fill([x1 x1 x2 x2],[y1 y2 y2 y1],'r')
axis([0 2 y2 y1]),hold on
t = 0:1e-3:2*pi;
plot(t,sin(10*t))
  2 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!