Return Values that are Between Two Values
1 回表示 (過去 30 日間)
古いコメントを表示
I have this vector:
w_sorted = [0;0;0;0;1;2;19;60;78];
target = 2;
threshold = 20;
lower_thold = abs(target-threshold);
upper_thold = abs(target+threshold);
series = all(w_sorted >= lower_thold & w_sorted <= upper_thold);
I need series to return all values in the w_sorted vector that are between the lower and upper threshold.
However, I need series to return the actual values, not the logical, which all currently does. I've tried the following which did not work as I needed it to:
series = w_sorted(w_sorted > low_range & w_sorted < up_range);
series = w_sorted(w_sorted(:,1) >= low_range & w_sorted(:,1) <= up_range);
series = w_sorted < low_range | w_sorted > up_range;
0 件のコメント
回答 (1 件)
RAGHUNATHRAJU DASHARATHA
2022 年 11 月 1 日
As per my understanding you want to get the values between the lower and upper threshold from your vector.
I will try to explain it using your code with minor change.
w_sorted = [0;0;0;0;1;2;19;60;78];
target = 2
threshold = 20
lower_thold = abs(target-threshold)
upper_thold = abs(target+threshold)
series = w_sorted(w_sorted >= lower_thold & w_sorted <= upper_thold)
3 件のコメント
Torsten
2022 年 11 月 2 日
You don't need the number of values. You can simply use
m = mean(series)
参考
カテゴリ
Help Center および File Exchange で Time Series についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!