フィルターのクリア

Find if a value in a column is greater than a number and exclude the entire row

16 ビュー (過去 30 日間)
R2
R2 2015 年 4 月 27 日
編集済み: Stephen23 2015 年 4 月 28 日
I have a numerical array that consists of 9 columns, where I want to consider the values in one of these columns and determine if it is greater than 0.00001. If this condition is met for a particular value I want to exclude all of the other values in the other columns for that row. I have included an example of the data, where in this case I want to specifically look at the values in the 7th column.
Thanks!

採用された回答

Stephen23
Stephen23 2015 年 4 月 27 日
編集済み: Stephen23 2015 年 4 月 27 日
If A is that matrix of data, first we can check the seventh column:
A = [...];
idx = A(:,7) > 1e-5;
and then remove those rows using logical indexing:
A(idx,: ) = [];
Or it is likely to be better to keep the original data matrix intact and simply use the index vector idx when you need to extract that particular subset of data. Note you can also invert the index to get the remaining rows:
A = [...];
B = A(~idx,:);
Creating and using indices to access subsets of data is often simpler and faster than actually altering the original data matrices, as it simplifies the memory management that MATLAB has to perform when you change the matrices.
  3 件のコメント
R2
R2 2015 年 4 月 27 日
Any idea how I would do this for a value between two numbers? so > 1e-5 and < 1
Stephen23
Stephen23 2015 年 4 月 28 日
編集済み: Stephen23 2015 年 4 月 28 日
Simply define the index with those conditions:
idx = 1e-5<A(:,7) & A(:,7)<1;

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by