MATLAB: Find values in vector present in cell array

matrix manipulation

i have a cell array cA and vector V with values
cA = {[11,21,3;14,5,63], [11,22], [33;95;66;7]};
V = [14 22 33 66];
i wanted to find which all values in V are there in cA and its position
output = { [ 0 0 0 1 0 0], [1 2], [3 0 4 0] }

Best Answer

out = cell(size(cA));
for i = 1:numel(out)
x = cA{i}';
[~,out{i}] = ismember(x(:)',V);
end
or with cellfun
[~,out] = cellfun(@(x)ismember(reshape(x',1,[]),V),cA,'un',0);