Mark specific values on a plot!
Show older comments
Hi consider the following plot:
x=1:100;
y=600+(1400-600).*rand(100,1);
plot(x,y)
How can I mark the y values between 900 and 1100? Thanks!
1 Comment
Rik
on 19 Oct 2017
With hold on and plotting a line over it with an increased line width you could emphasize a certain range.
Accepted Answer
More Answers (1)
Hellen Nassuna
on 8 Oct 2018
x=1:100;
y=600+(1400-600).*rand(100,1);
plot(x,y)
hold on;
yMark=NaN(1,100);%preallocation for speed
for i=1:1:length(y)
if(y(i)>=900 && y(i)<=1100)
yMark(i)=y(i);
end
end
plot(x,yMark,'->')
hold off
if true
% code
end
Categories
Find more on Graphics Performance 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!