toDel = false(1, numel(S));
for i1 = 1:numel(S)
data1 = S(i1).f1;
n1 = numel(data1);
for i2 = i1 + 1:numel(S)
if ~toDel(i2)
data2 = S(i2).f1;
n2 = numel(data2);
if n1 >= n2
if isequal(data1(1:n2), data2)
toDel(i2) = true;
end
elseif isequal(data1, data2(1:n1))
toDel(i1) = true;
end
end
end
end
S(toDel) = [];
Maybe "subset of" does not mean, that the first elements are equal. Then all(ismember()) might be, what you need instead of isequal.