How to Match Different Formatted Date Strings from Multiple Tables
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello, I need help with date strings.
I have 2 tables, Table 1 has timeseries with this time format: i.e. 2000-06-02_00:00:00
And Table 2 has this time format: i.e. 02.06.2000 (day/month/year)
I have to create a loop starting from "2000-06-02" with 1 day increments for next 5 days, then find the matching row number on Table 2's date column, then parse the needed data from the corresponding row number on another column, but I am stuck at finding the correct functions for the task. I wrote the following part of my code but got a "DATENUM Failed, caused by Cannot parse date' error.
On code "time" is time column of Table 1, and "obstime" is of Table 2.
Any help is much appreciated.
Thanks in advance.
P=24;
D=5;
for N=1:D
if N == 1
Date{N}=datenum(datestr(datenum(time(1,1)),'dd.mm.yyyy'));
y=find(obstime,Date{N});
Obs_out(N)=PtData(y);
Day_out(N,1)=mean(A(1:23));
elseif N > 1
d=Date{N-1};
dn=datenum(datestr(d+1));
y=find(obstime,dn);
Obs_out(N)=PtData(y);
S=P+23;
Day_out(N,1)=mean(A(P:S));
P=S+1;
댓글 수: 2
Thomas
2012년 9월 26일
Why are you going from datenum-datestr-datenum
b1={'02.06.2000'}
datenum(b1,'DD.MM.YYYY')
ans =
730487.00
Works just fine..
답변 (0개)
참고 항목
카테고리
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!