I try to find unique arrays in a cell array. Suppose I have 6 cells with the following vectors:
a{1}=[1 2];
a{2}=[1 2 3];
a{3}=[2 3 4];
a{4}=[1 2];
a{5}=[1 2 3];
a{6}=[2 3 4];
Then the result should be [1 2]
, [1 2 3]
and [2 3 4]
. I used u=(cellfun(@unique,a,'Un',0))
, but it doesn't work, How can I do this?
Here a solution :
u = unique(cellfun(@num2str,a,'Un',0));
To transform them back to vector :
u2 = cellfun(@str2num,u,'Un',0);