필터 지우기
필터 지우기

Combine/join table based on common names

조회 수: 4 (최근 30일)
Mohammed Kamruzzaman
Mohammed Kamruzzaman 2015년 4월 21일
댓글: Star Strider 2015년 4월 21일
I have two tables with sting and their length is different. I want to make a table with common string;
CSN_PROV1_20130209 CSN_PROV1_20130209
CSN_WADC1_20131004 CSN_WADC1_20131004
CSN_PROV1_20130320 CSN_PROV1_20130320
CSN_WADC1_20131203 CSN_WADC1_20130430
CSN_BEHI1_20130127 CSN_PROV1_20131111
CSN_BEHI1_20130127
I want my new table as:
CSN_PROV1_20130209
CSN_WADC1_20131004
CSN_PROV1_20130320
CSN_BEHI1_20130127

채택된 답변

Star Strider
Star Strider 2015년 4월 21일
I had to reconstruct your arrays so they would work. I believe the intersect output is what you want, but I listed the unique output as well:
T1 = ['CSN_PROV1_20130209'
'CSN_WADC1_20131004'
'CSN_PROV1_20130320'
'CSN_WADC1_20131203'
'CSN_BEHI1_20130127'];
T2 = ['CSN_PROV1_20130209'
'CSN_WADC1_20131004'
'CSN_PROV1_20130320'
'CSN_WADC1_20130430'
'CSN_PROV1_20131111'
'CSN_BEHI1_20130127'];
Tu = unique([T1; T2], 'rows') % Unique Elements
Ti = intersect(T1, T2, 'rows') % Intersecting Elements
producing:
Tu =
CSN_BEHI1_20130127
CSN_PROV1_20130209
CSN_PROV1_20130320
CSN_PROV1_20131111
CSN_WADC1_20130430
CSN_WADC1_20131004
CSN_WADC1_20131203
Ti =
CSN_BEHI1_20130127
CSN_PROV1_20130209
CSN_PROV1_20130320
CSN_WADC1_20131004
Apologies for the delay — we had an inundation of Korean spam tonight, and I was busy deleting it.
  댓글 수: 2
Mohammed Kamruzzaman
Mohammed Kamruzzaman 2015년 4월 21일
Thank you so much Star Strider. Your answer is perfect and awesome.
Star Strider
Star Strider 2015년 4월 21일
My pleasure!

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

추가 답변 (0개)

카테고리

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