フィルターのクリア

How to remove data points above or below a value in an array, nicely!

7 ビュー (過去 30 日間)
ljp64
ljp64 2018 年 8 月 2 日
コメント済み: OCDER 2018 年 8 月 2 日
In my array (PRE_A, imported from a csv), I want to remove any data point over 900 or below 750, so have written the code below. How do I write this in less lines of code?
Thank you :)
PRE_A = PRE_A(PRE_A(:,2) > 750, :);
PRE_A = PRE_A(PRE_A(:,3) > 750, :);
PRE_A = PRE_A(PRE_A(:,4) > 750, :);
PRE_A = PRE_A(PRE_A(:,5) > 750, :);
PRE_A = PRE_A(PRE_A(:,6) > 750, :);
PRE_A = PRE_A(PRE_A(:,7) > 750, :);
PRE_A = PRE_A(PRE_A(:,8) > 750, :);
PRE_A = PRE_A(PRE_A(:,9) > 750, :);
PRE_A = PRE_A(PRE_A(:,2) < 920, :);
PRE_A = PRE_A(PRE_A(:,3) < 920, :);
PRE_A = PRE_A(PRE_A(:,4) < 920, :);
PRE_A = PRE_A(PRE_A(:,5) < 920, :);
PRE_A = PRE_A(PRE_A(:,6) < 920, :);
PRE_A = PRE_A(PRE_A(:,7) < 920, :);
PRE_A = PRE_A(PRE_A(:,8) < 920, :);
PRE_A = PRE_A(PRE_A(:,9) < 920, :);

採用された回答

OCDER
OCDER 2018 年 8 月 2 日
編集済み: OCDER 2018 年 8 月 2 日
I think this is what you're trying to do:
GoodRow = ~any(PRE_A(:, 2:9) <= 750 | PRE_A(:, 2:9) >= 920, 2)
PRE_A = PRE_A(GoodRow, :)
Translation:
GoodRow = ~ any (PRE_A(:, 2:9) <= 750 | PRE_A(:, 2:9) >= 920, 2)
Good rows do NOT have any value <= 750 OR any value >= 920, across all columns
  4 件のコメント
ljp64
ljp64 2018 年 8 月 2 日
You're a gem! Thankyou :)
OCDER
OCDER 2018 年 8 月 2 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by