MATLAB Answers

Extracting values that are greater than the threshold

48 views (last 30 days)
WILLBES BANDA
WILLBES BANDA on 28 Mar 2020
Commented: WILLBES BANDA on 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 Comments

Sign in to comment.

Accepted Answer

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

  1 Comment

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

Sign in to comment.

More Answers (1)

Products

Community Treasure Hunt

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

Start Hunting!

Translated by