Populate .csv with specific times and dates

조회 수: 2 (최근 30일)
Louise Wilson
Louise Wilson 2020년 3월 12일
댓글: Bhaskar R 2020년 3월 12일
Hello,
I am looking to create a spreadsheet which has values that span a time period of interest.
For example, say my data collection period is from 30 May 2019-30 June 2019, between the hours of 0600-2030 each day. I am collecting data every ten minutes.
I have figured out how to get the time to iterate between two dates and times in ten minute intervals, but how do I stop from including the times in the evening and morning of each day that I'm not interested in? After 2030 on each date, I want to skip to 0600 on the subsequent date.
t1=datetime(2019,5,30,6,0,0); %datetime 1
t2=datetime(2019,10,30,20,30,00); %datetime 2
t=t1:minutes(10):t2 %10 minutes intervals between the two times
t=t'; %transpose from one column to one row

답변 (1개)

Bhaskar R
Bhaskar R 2020년 3월 12일
required_times = t(hour(t)>12 & hour(t)<17) % where timings between 12 to 17 hours of the data
  댓글 수: 2
Louise Wilson
Louise Wilson 2020년 3월 12일
Thanks Bhaskar, this works. How do I be more specific in terms of time e.g. specify 2030 rather than 2100?
required_times = t(hour(t)>0600 & hour(t)<2030)
%doesnt work
Bhaskar R
Bhaskar R 2020년 3월 12일
required_times = t(hour(t)>6+0/60 & hour(t)<20+30/60); % need to add normalized minutes

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

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by