set difference between two cell arrays

1 次查看(过去 30 天)
I have two cell arrays
A={ [2] [1x2 double]}
B={[2],[3]}
I want to perform set difference operation such that
C=setdiff(A,B);
and answer should be [1x2 double]
what should I do?

采纳的回答

Stephen23
Stephen23 2019-12-30
编辑:Stephen23 2019-12-30
>> A = {2,[2,3]};
>> B = {2,3};
>> [XA,XB] = ndgrid(1:numel(A),1:numel(B));
>> X = arrayfun(@(xA,xB)isequal(A{xA},B{xB}),XA,XB);
>> Z = A(~any(X,2));
>> Z{:}
ans = [2,3]

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by