set difference between two cell arrays

2 vues (au cours des 30 derniers jours)
Niharika  Nayak
Niharika Nayak le 30 Déc 2019
Commenté : Niharika Nayak le 30 Déc 2019
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?

Réponse acceptée

Stephen23
Stephen23 le 30 Déc 2019
Modifié(e) : Stephen23 le 30 Déc 2019
>> 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]
  1 commentaire
Niharika  Nayak
Niharika Nayak le 30 Déc 2019
Thank you so much it works

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by