필터 지우기
필터 지우기

Filter only specific month from date serial number

조회 수: 2 (최근 30일)
AA
AA 2017년 3월 16일
답변: Peter Perkins 2017년 3월 16일
Hi guys, I got a column with a date serial number and I would like to filter only the month of march. What is the coding for that?

채택된 답변

Peter Perkins
Peter Perkins 2017년 3월 16일
Unless you're using a version prior to R2014b, use datetimes:
>> dn = 736696 + 90*rand(10,1)
dn =
736755.016662924
736699.214051072
736772.421637528
736780.059392298
736757.086163937
736764.196611752
736762.881922131
736731.300431758
736754.993010116
736711.406801903
>> d = datetime(dn,'ConvertFrom','datenum')
d =
10×1 datetime array
01-Mar-2017 00:23:59
04-Jan-2017 05:08:14
18-Mar-2017 10:07:09
26-Mar-2017 01:25:31
03-Mar-2017 02:04:04
10-Mar-2017 04:43:07
08-Mar-2017 21:09:58
05-Feb-2017 07:12:37
28-Feb-2017 23:49:56
16-Jan-2017 09:45:47
>> (d.Month == 3)
ans =
10×1 logical array
1
0
1
1
1
1
1
0
0
0
Prior to 14b, use datevec.

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by