MATLAB: Set of ranges in vector.

inrangeMATLABrangevectors

I have a pool of 30 vectors with a set of values in them much like this(although much longer):
V = [a b c d e…]
V1 = [3.4 20.2 75.6 91.3 120.7…]
V2 = [3.2 21.7 76.6 94.3 122.7…]
V3 = [4.1 23.8 78.1 93.9 125.8…]
and so on.
As it can be seen, each value fluctuates slightly and within a range.
now I have a range of acceptable values for a b c d and e like this:
a accept = [2 5]; b accept = [20 25]; c accept = [70 80]; d accept = [90 100]; e accept = [120 130]
I need to be able to pick one vector (say V1) and check if all the values for a, b, c, d and e are within range.
I know how to do that for a single value this way:
inRange = (V1>2)&(V1<5);
ACCEPT V1 = V1(inRange);
This will spit out ACCEPT V1 = 3.4; as 3.4 is within range thus it makes it to output. Where I am stuck is: how can I make it look for multiple ranges so all the values will make it through (provided they fall in the range)?
another thing: I am trying to use this to filter out phantom readings(I shall call them PH), as in some of the vectors i have random extras readings that fall out of range such as:
V4 = [1.3 3.2 22.9 40.5 74.0 97.7 125.1 203.3…]
In other words: V4 = [PH 3.2 22.9 PH 74.0 97.7 125.1 PH…]
my end goal is to be able to run those ranges and get a corrected vector out that eliminates those phantom readings, getting ACCEPT V4 = [3.2 22.9 74.0 97.7 125.1…]

Best Answer

maximums = [5 25 80 100 130];
minimums = [2 20 70 90 120];
yesOrNoVector = (v1<maximums)&(v1>minimums);
% this outputs a vector or 0's and 1's where 1 means accept
acceptOrReject = all(yesOrNoVector);
% this is your answer. It returns 0 if at least one element of V1 is out of range. See >>doc all