MATLAB Answers

Extracting values that are greater than the threshold

조회 수: 69(최근 30일)
WILLBES BANDA
WILLBES BANDA 28 Mar 2020
댓글: WILLBES BANDA 28 Mar 2020
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

  댓글 수: 0

댓글을 달려면 로그인하십시오.

채택된 답변

Peng Li
Peng Li 28 Mar 2020
outAlert = Alert(Alert(:, 3) > 21, :);
should be what you want to have

  댓글 수: 1

WILLBES BANDA
WILLBES BANDA 28 Mar 2020
It works perfectly fine, Thank you very very much

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Torsten
Torsten 28 Mar 2020
OxygenAlt = Alert(Alert(:,3)>21)

  댓글 수: 1

WILLBES BANDA
WILLBES BANDA 28 Mar 2020
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