How to filter a certain range of values in a column vector of thousand rows

74 ビュー (過去 30 日間)
Gali Musa
Gali Musa 2018 年 5 月 24 日
コメント済み: jhoan giraldo 2022 年 4 月 26 日
I want to find a range of values in a column vector of a minimum value of 20% and a maximum value of 90%. The column has 2000 rows. suppose i want to filter values between a range of 70% to 80%. sample code for i = 1:length(PP) if (70% <= PP(i) <= 80%) filtered_PP(i) = PP(i) end end I later separate it and still i'm not getting the correct the answer
for i = 1:length(PP) if (70% <= PP(i) && 80% >= PP(i)) filtered_PP(i) = PP(i) end end

採用された回答

TAB
TAB 2018 年 5 月 25 日
PP = (0:100)';
filtered_PP_Idx = find((PP>=73 & PP<=80));
filtered_PP = PP(PP>=70 & PP<=80);
  3 件のコメント
Ian Larson
Ian Larson 2022 年 4 月 8 日
Say PP was on a time x axis. How would I find the corresponding X values?
jhoan giraldo
jhoan giraldo 2022 年 4 月 26 日
You already have the indexes in filtered_PP_Idx. If you have for example a 'time' vector:
time_indexed=time(filtered_PP_Idx);

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by