How do shade different area with specific y interval
Show older comments
My codes are as follows:
clear
x = 0:0.01:9;
y = sqrt(x);
plot(x, y)
hold on;
x = 1:0.01:9;
[m n]=size(x)
y1=ones(1,n);
plot(x,y1,'r--')
hold on
x = 4:0.01:9;
[m n]=size(x)
y2=ones(1,n)*2;
plot(x,y2,'r--')
hold on
text(2.8, 2,'$y=\sqrt x$', 'interpreter','latex')
text(5.5, 0.2,'Shade this area by green')
text(5.5, 1.2,'Shade this area by red')
text(5.5, 2.2,'Shade this area by blue')
1 Comment
Wan-Yi Chiu
on 25 Aug 2021
Accepted Answer
More Answers (0)
Categories
Find more on Labels and Annotations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!