Borrar filtros
Borrar filtros

find column variable sharing another column variable (table)

1 visualización (últimos 30 días)
Dave
Dave el 6 de Abr. de 2020
Respondida: Ameer Hamza el 6 de Abr. de 2020
I have two variables where name1 shares name2 in some cases.
unique(name1) is larger than unique(name2)
name1={'ABC';'ABC';'DEF';'GHI';'GHI'};
name2={'XX1';'XX1';'XX1';'XX2';'XX2'};
T=table(name1, name2);
In this example ABC and DEF share XX1.
How can I find the location of the shared cases? In this example would be rows 1, 2, 3

Respuestas (1)

Ameer Hamza
Ameer Hamza el 6 de Abr. de 2020
name2={'XX1';'XX1';'XX1';'XX2';'XX2'};
groups = findgroups(name2)
ans =
1
1
1
2
2

Categorías

Más información sobre Tables en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by