MATLAB: Removing element from all arrays in cell array of 1-dimensional arrays

cell arrayremoval

I have a cell array out = cell(n,1), and each out{j}, 1<= j <= n, is a vector of integers. These vectors have different lengths. How can I efficiently remove an integer k from all vectors containing k?

Best Answer

newout = cellfun(@(x)setdiff(x,k),out,'un',0);