Find Elements in Range - MATLAB Cody - MATLAB Central

Problem 2589. Find Elements in Range

Difficulty:Rate

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

55.24% Correct | 44.76% Incorrect
Last Solution submitted on Jun 01, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
3
3

Problem Recent Solvers67

Suggested Problems

More from this Author9

Problem Tags

Community Treasure Hunt

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

Start Hunting!