Filter löschen
Filter löschen

joint find statement using ismember & ~ismember

1 Ansicht (letzte 30 Tage)
wesso Dadoyan
wesso Dadoyan am 18 Mai 2016
Bearbeitet: Stephen23 am 18 Mai 2016
Hi,
I wrote the following code: xe=find(ismember(ID,IDA) & ~ismember(DateID,DateIDA)); but it is failing to capture what I want I want to find the observations where the IDs matches (i,e the ids in the ID column exist in the IDA column but the dates respective of the ID column don't exist in the dates respective to IDA column) example: ID=[ 1;2;....20]; IDA=[1;2;....40]; DateID=[729115;729206;.....729298] DateIDA=[729115;733393;.....729298]
what i want xe to find is that for ID=2 & date=729206 I don't have an IDA=2 with a date=729206. I would appreciate any help in this joint find statement

Akzeptierte Antwort

Stephen23
Stephen23 am 18 Mai 2016
Bearbeitet: Stephen23 am 18 Mai 2016
It works fine for me, using your sample data:
>> ID = [1;2;20];
>> IDA = [1;2;40];
>> DateID = [729115;729206;729298];
>> DateIDA = [729115;733393;729298];
>> ismember(ID,IDA) & ~ismember(DateID,DateIDA)
ans =
0
1
0
You might need to round your date numbers to integer before making this comparison.

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by