Effacer les filtres
Effacer les filtres

How to delete elements which in cell?

2 vues (au cours des 30 derniers jours)
vx2008
vx2008 le 24 Déc 2015
Commenté : vx2008 le 25 Déc 2015
Now I have DataA and DataB as below:
DataA =
{5x1 cell} [5x1 double]
DataB =
{5x1 cell} [5x1 double]
DataA{1} =
'2015/05/04'
'2015/05/05'
'2015/05/06'
'2015/05/08'
'2015/05/09'
DataB{1}=
'2015/05/04'
'2015/05/05'
'2015/05/06'
'2015/05/07'
'2015/05/08'
DataA{2} =
1.0e+03 *
4.4413
4.4799
4.3116
4.1979
4.1530
DataB{2} =
17.2400
16.9700
16.3200
16.2700
16.4300
Now I want to find the difference between DataA{1} and DataB{1} first; then delete the different rows in DataA and DataB; For example, DataA{1} has '2015/05/07' which DataB{1} doesn't have; so DataA{1}(4) and DataA{2}(4) should be deleted; and the same other different points.
My question is how to do this?
thank you!
  1 commentaire
dpb
dpb le 24 Déc 2015
doc ismember % and friends

Connectez-vous pour commenter.

Réponse acceptée

Jan
Jan le 24 Déc 2015
[indexA, indexB] = ismember(DataA{1}, DataB{1});
DataA{1}(indexA) = [];
DataA{2}(indexA) = [];
DataB{1}(indexB) = [];
DataB{2}(indexB) = [];
See also: setdiff.
  1 commentaire
vx2008
vx2008 le 25 Déc 2015
thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Types 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