MATLAB: Find unique values in nested cell array

nested cell arrayunique

I have a nx1 cell array, with each row containing another cell array of variable size. I would like to isolate unique values in each nested array, while still keeping the structure of the larger cell array.
Help would be greatly appreciated. Thanks!

Best Answer

I’m not sure what you want.
This will give you the unique values amongst all the nested cells in your cell array:
C = {{randi(99, 1, 10)}; {randi(99, 1, 5)}; {randi(99, 1, 20)}};
C1 = [C{:}];
Cu = unique([C1{:}]);