필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Appending data based on same dates

조회 수: 1 (최근 30일)
Lee
Lee 2018년 8월 27일
마감: MATLAB Answer Bot 2021년 8월 20일
I have two long tables. The first table (A) has two columns. The first indicates a date and the second indicates a value. A sample of the table is illustrated below:
A =
06-Jun-2015 00:00:00 1
07-Jun-2015 00:00:00 6
08-Jun-2010 00:00:00 1
08-Jun-2011 00:00:00 1
09-Jun-2010 00:00:00 52
09-Jun-2011 00:00:00 1
The second table contains a sample id and dates.
B =
"ahfeog" '08-Jun-2011 06:00:00'
"ahegao" '09-Jun-2010 21:00:00'
"agejho" '07-Jun-2015 03:00:00'
"ehagoa" '06-Jun-2015 06:00:00'
"eozjmv" '06-Jun-2015 18:00:00'
Ignoring the times, I want to be able to append the two tables together based on the date. My problem is that table B is significantly larger than table A and has repeat dates. Ideally my output would look like this:
Out =
"ahfeog" '08-Jun-2011 06:00:00' 1
"ahegao" '09-Jun-2010 21:00:00' 52
"agejho" '07-Jun-2015 03:00:00' 6
"ehagoa" '06-Jun-2015 06:00:00' 1
"eozjmv" '06-Jun-2015 18:00:00' 1
Could someone help me figure out how to do this?

답변 (2개)

Paul Shoemaker
Paul Shoemaker 2018년 8월 27일
Hello Lee,
You might want to convert these two tables to timetables and then combine them using various functions, such as "synchronize."
Matlab has some examples here.
Paul Shoemaker
  댓글 수: 1
Lee
Lee 2018년 8월 27일
Hello Paul Shoemaker,
Thank you for the response. Unfortunately, synchronize does not handle replicate dates and instead deletes one of the variables. The output I got was:
'08-Jun-2010 00:00:00' '<undefined>' 1
'09-Jun-2010 00:00:00' 'ahegao' 52
'08-Jun-2011 00:00:00' 'ahfeog' 1
'09-Jun-2011 00:00:00' '<undefined>' 1
'06-Jun-2015 00:00:00' 'ehagoa' 1
'07-Jun-2015 00:00:00' 'agejho' 6
Any other suggestions?

BasO
BasO 2018년 11월 12일
Hi Lee,
Try to format the dates to 'dd-mmm-yyyy', this allows Matlab to syncronize as Paul said in his link.
Regards,

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by