Remove dulpicate rows of cell array
2 views (last 30 days)
Show older comments
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
1 Comment
Dyuman Joshi
on 9 Dec 2021
You can use for loops to compare rows using isequal and delete the duplicate rows.
Answers (1)
Awais Saeed
on 9 Dec 2021
Edited: Awais Saeed
on 9 Dec 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')
0 Comments
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!