How to delete elements which in cell?

1 次查看(过去 30 天)
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!

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Types 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by