フィルターのクリア

specify array with values

3 ビュー (過去 30 日間)
Syeda Amberin
Syeda Amberin 2019 年 7 月 2 日
コメント済み: Steven Lord 2019 年 7 月 2 日
Hi,
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?
Thanks

採用された回答

Steven Lord
Steven Lord 2019 年 7 月 2 日
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)
  2 件のコメント
Syeda Amberin
Syeda Amberin 2019 年 7 月 2 日
Thanks. I have applied this method. But this means I will have to create a second table which I am avoiding. Your time is appreciated.
Steven Lord
Steven Lord 2019 年 7 月 2 日
No. I built the table T just to show the results.
rng(0, 'twister');
x = rand(10, 1);
T = table(x);
mask = (T.x > 0.25) & (T.x < 0.75);
T(mask, :) % Sub-table
T{mask, 'x'} % Just the contents of the x variable from T

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by