필터 지우기
필터 지우기

How to plot data only certain days of a year.

조회 수: 1 (최근 30일)
Ro
Ro 2021년 5월 6일
편집: Ro 2021년 5월 6일
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

답변 (1개)

KSSV
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))
  댓글 수: 1
Ro
Ro 2021년 5월 6일
편집: Ro 2021년 5월 6일
Hi Using code above and real dates, and corresponding cyclist data I am getting ERROR USING DATATIME/HORZCAT DIMENSIONS OF MATRICES BEING CANCATENATED ARE NOT CONSISTENT
For each one of those dates above has number of cyclist data for each date. So for example Jan 10th has 82 cyclist Jan 12th has 829 cyclist Jan 14th has 176 cyclist. And so on... Same for the extracted dates for feb and each date extracted for March etc....each date had an a #of cyclist. How do you plot the corresponding cyclist for each date of each month. While still maintaining dates and everything on 1 graph.

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

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by