Search code examples
stringmatlabduplicatescell-array

Merge string cell arrays and remove duplicates


I've the following string cell arrays:

a = { 'A', 'B', 'C', 'D'};
b = { 'E', 'A', 'F', 'D'};

How can I merge them and remove duplicate strings, so I can obtain the following string cell array?

c = { 'A', 'B', 'C', 'D', 'E', 'F' }

Solution

  • You can use union:

    union(a, b)