MATLAB: Specify array with values


I am trying to set up an array of values with lower and upper bounds. The lower bound (lb) is .1 and the upper bound (ub) is .25. I also have a table called Tab. I want to find all values in Tab(:,3) as long as they are within [lb and ub]. I am trying to use ismember because I am specifying for other columns using ismember. It would be nice if I could extract all rows from Tab(:,3) that fall between ub and lb using ismember. Any help?

Best Answer

  • ismember isn't the right tool for this task. Use the greater-than (>) and less-than (<) operators.
    rng(0, 'twister');
    x = rand(10, 1);
    mask = (x > 0.25) & (x < 0.75);
    T = table(x, mask, 'VariableNames', {'data', 'inRange'})
    xInRange = x(mask)