How to add a line after every seventh Value!

조회 수: 3 (최근 30일)
Sophia
Sophia 2020년 1월 21일
편집: Sindar 2020년 1월 21일
I am looking for a way to add a line after seventh point to show the breaking point time intervals. The matrix has 2544 values and i am plotting every 30th value in this figure.seasonality_bg_tpd.tif

답변 (1개)

Sindar
Sindar 2020년 1월 21일
편집: Sindar 2020년 1월 21일
You can add vertical lines using xline:
% create sample data
x = 1:2544;
y = rand(1,length(x));
% store indices that will be plotted
inds = 1:30:length(x);
% store indices of every 7th point (starting at 8th)
inds_7 = inds(8:7:end);
plot(x(inds),y(inds))
for inds_7
% plot a vertical line between the 7th point and the next point, the 14th and 15th, etc.
xline( (x(inds_7-1)+x(inds_7))/2 )
end

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by