How to get output of [110,40] from input of FindAbnormal([65, 95, 110, 80, 40]) using relational and logical operators?
6 views (last 30 days)
Show older comments
Ismael Abadin
on 11 Apr 2016
Commented: Ismael Abadin
on 11 Apr 2016
The problem is: The resting heart rate for an average adult between 60 - 100 beats per minute, inclusive. Assign row array heartExtracted with all values in row array heartReadings that do not fall within the normal range.
My code right now is:
function heartExtracted = FindAbnormal(heartReadings)
% heartReadings: Array of hourly heart rate readings
% Create a logical indexing array to identify readings that are not 60-100
abnormalReadings = heartReadings((heartReadings < 60) & (heartReadings > 100));
% Assign heartExtracted all values in heartReadings that do not fall
% within the normal range
heartExtracted = heartReadings(abnormalReadings);
end
but it's giving me an empty matrix when I run it. Can someone explain why it's giving me an empty matrix, and how to properly write it?
0 Comments
Accepted Answer
Azzi Abdelmalek
on 11 Apr 2016
Edited: Azzi Abdelmalek
on 11 Apr 2016
Use logical or | instead of logical and &
a number that satisfies a two conditions <60 and >100 doesn't exist! But you can find numbers that are <60 or >100
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!