Remove dulpicate rows of cell array

5 visualizzazioni (ultimi 30 giorni)
Christos Traianos
Christos Traianos il 9 Dic 2021
Modificato: Awais Saeed il 9 Dic 2021
Hi,
i need to remove duplicated rows of cell array and keep the row only one time.
For example from array 3x5:
{'800AL'} {'800AL'} {'800AL'} {'800AL'} {'800AL'}
{'700AL'} {'700AL'} {'700AL'} {'700AL'} {'700AL'}
{'800AL'} {'800AL'} {'800AL'} {'800AL'} {'800AL'}
i would like to keep a table with dimension 2x5:
{'800AL'} {'800AL'} {'800AL'} {'800AL'} {'800AL'}
{'700AL'} {'700AL'} {'700AL'} {'700AL'} {'700AL'}
I tried the unique function but i can't keep the whole row.
Any idea on that?
Thanks in advance

Risposte (1)

Awais Saeed
Awais Saeed il 9 Dic 2021
Modificato: Awais Saeed il 9 Dic 2021
C = {{'800AL'} {'800AL'} {'800AL'} {'800AL'} {'800AL'}
{'700AL'} {'700AL'} {'700AL'} {'700AL'} {'700AL'}
{'800AL'} {'800AL'} {'800AL'} {'800AL'} {'800AL'}};
cell2str = string(C); % convert cell to string
unique(cell2str, 'rows', 'stable')
ans = 2×5 string array
"800AL" "800AL" "800AL" "800AL" "800AL" "700AL" "700AL" "700AL" "700AL" "700AL"

Categorie

Scopri di più su Cell Arrays 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