Combine/join table based on common names

1 view (last 30 days)
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

Accepted Answer

Star Strider
Star Strider on 21 Apr 2015
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 Comments
Mohammed Kamruzzaman
Mohammed Kamruzzaman on 21 Apr 2015
Thank you so much Star Strider. Your answer is perfect and awesome.

Sign in to comment.

More Answers (0)

Categories

Find more on Data Type Identification in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!