Azzera filtri
Azzera filtri

Combine/join table based on common names

4 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Data Type Identification in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by