How to plot data only certain days of a year.
조회 수: 2 (최근 30일)
이전 댓글 표시
How to plot or bar data for only certain days of the year. X axis will 365 days Y axis will have cyclist
Eg if the year has 365 days and Jan has cyclist data for day 10, day 12 and day 14 of that month.
Feb has cyclist data for day 1,3,7,8,10,12,14 for that month March has cyclist data for day 12, 15,20,22, 23, 24, 25, 27 for that month.. And so on... How to I get to plot these EXACT days of the month on the x axis without data for other days of the months and year? I want to keep each months data under their assigned month but still show if it’s day 2 or 11 etc I want all this data on 1 graph as I said with y axis being cyclist and x axis being days each month
댓글 수: 0
답변 (1개)
KSSV
2021년 5월 6일
You may proceed something like below:
t = datetime(2020,1,1):datetime(2020,12,31) ;
y = rand(size(t)) ; % random y-axis values for demo
% make required dates to plot
jan_t = datetime(2020,1,[10 12 14]) ;
feb_t = datetime(2020,2,[1,3,7,8,10,12,14]) ;
mar_t = datetime(2020,3,[12, 15,20,22, 23, 24, 25, 27]) ;
ti = [jan_t feb_t mar_t] ;
% plot
[idx,ia] = ismember(t,ti) ;
plot(ti,y(idx))
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!