MATLAB: Matlab OR | operator not working

or operator

Hi I have a dataset (x.data) of 90,000 or so indices with values at each index. I am trying to pull the indices at certain values 21009 and 21003
When I sum(x.data==21009) I get 80, which is correct (ie, there are 80 indices with values of 21009). When I sum(x.data==21003) I get 150, also expected.
However when I try to pull both sum(x.data== 21009 | 21003) I get 90,000 and when I look at the output for x.data==21009 | 21003) it's just a column of 1s. It's probably something obvious but what am I missing?

Best Answer

To the best of my knowledge the or operator doesn't work quite like that. You need to set separate conditions on each side of the or, rather than multiple values to check for.
x.data == 21009 | x.data == 21003;