I have a cell array where each element consists of a vector of ids. I like to compute the union of all elements in the cell array. This is my current solution, but I feel it can be vectorized or have a more elegant solution:
union_ids = union(encounter_ids{1},encounter_ids{2});
for i=3:1:numel(encounter_ids);
union_ids = union(union_ids,encounter_ids{i});
end