Combine/join table based on common names

4 次查看(过去 30 天)
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.

更多回答(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