Reputation: 31
My cell array S <1x4cell>
contains 4 cell arrays (<108x1cell>
,<106x1cell>
,<111x1cell>
,<115x1cell>
), each of which contains a list of roughly a hundred file paths.
I want to merge them in order to get one single cell with all my paths. Is there a single function to do that?
Upvotes: 3
Views: 342
Reputation: 25232
Concatenate your cell arrays and use unique
:
%// example data
A ={'a';
'b';
'c';
'd'};
B = {'a';
'e';
'f'};
C = {'g';
'a';
'c'};
%// merge cells
merged = [A(:); B(:); C(:)]
%// or
merged = cat(1, A(:), B(:), C(:))
%// remove duplicates
filtered = unique(merged)
or assumiming you already have the cell array S = merged
, do the following:
S = { A, B, C }
%// remove duplicates
filtered = unique(cat(1,S{:}))
Upvotes: 5