I have cell array that is as follow:
S{1} = [10,20,30,40,50];
S{2} = [10,20,40,50];
S{3} = [10,50,510];
S{4} = [10,20,70,40,60];
S{5} = [20,40];
and, i need to find rows of cell that are subitem of:
[10,20,30,40,50,60]
for above example result is :
1,2,5
because row 1 and row 2 and and row 5 only have subitems of [10,20,30,40,50,60] .
in my work cell array is big. and i need a fast code.
Let
Then, you can apply
ismemberandallto each cell's contents viacellfun. The result is a logical vector, from which you obtain the desired indices withfind:An alternative (I don't know which one will be faster in your case) is to replace
ismemberby computing all pairwise comparisons withbsxfunand then applyingany: