필터 지우기
필터 지우기

For loop in a plot

조회 수: 2 (최근 30일)
Sayantan Sahu
Sayantan Sahu 2018년 4월 5일
댓글: Star Strider 2018년 4월 5일
I want to plot a line for a certain number of years. The starting point for each line on the y-axis is the 5th percentile and it extends to the 95th percentile. I have the following code,
for ii=1:12
plot([year(ii) year(ii)],[array_5(ii) array_95(ii)],'r','Linewidth',2.4)
end
However, it plots the line only for the last year. What modification do I need for this piece of code ?

채택된 답변

Star Strider
Star Strider 2018년 4월 5일
Use the hold (link) function, or alternatively:
hAxes = axes('NextPlot', 'add');
for ii = 1:12
plot(hAxes,[year(ii) year(ii)],[array_5(ii) array_95(ii)],'r','Linewidth',2.4)
end
  댓글 수: 2
Sayantan Sahu
Sayantan Sahu 2018년 4월 5일
Thanks it works !!!
Star Strider
Star Strider 2018년 4월 5일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by