Extracting values that are greater than the threshold

92 ビュー (過去 30 日間)
WILLBES BANDA
WILLBES BANDA 2020 年 3 月 28 日
コメント済み: WILLBES BANDA 2020 年 3 月 28 日
the Alert vector below is a combination of time in hours and minutes(column 1 and 2 respectively) and corresponding oxygen values (column 3). The threshold of oxygen is 21 and i want to store only values greater than 21 and their corresponding times in a (nx3) OxygenAlt vector. When i run the code below, i get the values of the unchanged Alert vector and they are not stored the way i want, please help.
Alert = 1.0000 12.0000 24.3687
2.0000 24.0000 19.3810
3.0000 36.0000 19.5573
4.0000 48.0000 18.9562
6.0000 0 22.3963
7.0000 12.0000 21.6010
8.0000 24.0000 22.6534
9.0000 36.0000 22.0820
10.0000 48.0000 21.1834
12.0000 0 19.5970
13.0000 12.0000 19.5775
14.0000 24.0000 23.5089
15.0000 36.0000 20.4282
16.0000 48.0000 20.8580
18.0000 0 23.5719
19.0000 12.0000 19.1469
20.0000 24.0000 20.9754
21.0000 36.0000 22.6969
when i run this code i get incorrect answers, please help
Alert = [OxygenTime Oxygen]
O = [Oxygen];
for Col = 1:1:length(Oxygen)
n = Alert(:,3)./21 ;
if n > 1
OxygenAlt = [Alert]
end
end

採用された回答

Peng Li
Peng Li 2020 年 3 月 28 日
outAlert = Alert(Alert(:, 3) > 21, :);
should be what you want to have
  1 件のコメント
WILLBES BANDA
WILLBES BANDA 2020 年 3 月 28 日
It works perfectly fine, Thank you very very much

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

その他の回答 (1 件)

Torsten
Torsten 2020 年 3 月 28 日
OxygenAlt = Alert(Alert(:,3)>21)
  1 件のコメント
WILLBES BANDA
WILLBES BANDA 2020 年 3 月 28 日
It also works just fine, thank you very much

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by