Problem 2589. Find Elements in Range
Based on a question on MATLAB Answers.
Find all the elements of a vector whose difference, regardless of position is less or equal than a given range.
Example
A = [1 4 7 10 2 8]; range = 1; inrange = [1 0 1 0 1 1]; % since diff(1, 2) <= 1 and diff(7, 8) <= 1
Solution Stats
Problem Comments
-
1 Comment
Ned Gulley
on 16 Sep 2014
I love the fact that you based this on a question from Answers! I kind of wanted to link back to it, but I can see that you might not want people to see your answer.
Solution Comments
Show commentsGroup

Indexing IV
- 15 Problems
- 28 Finishers
- Hard limit function
- How to reverse spdiags?
- Combine Data With Gaps
- Sum My Indices
- Longest Sequence of NaNs
- Find the same and successive values in a vector
- Pancake sorting - minimum flips.
- Elements with highest local average
- Neither minima nor maxima
- How to reverse spdiags?
- Find indices of diagonal elements
- Find Elements in Range
- Find the same and successive values in a vector
- Find the distance between runs
- Split array into pieces according to corresponding array
- How close to a hole
- Pancake sorting
- Pancake sorting - minimum flips.
- Combine Data With Gaps
- Sum My Indices
- Longest Sequence of NaNs
Problem Recent Solvers66
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!