MATLAB: How to delete elements which in cell

delete cell; cell edit;

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!

Best Answer

[indexA, indexB] = ismember(DataA{1}, DataB{1});
DataA{1}(indexA) = [];
DataA{2}(indexA) = [];
DataB{1}(indexB) = [];
DataB{2}(indexB) = [];
See also: setdiff.