Let two vectors lo and hi be given.
The job is to create a index vector like so
idx = [lo(1):hi(1) lo(2):hi(2) ...]
Where : is the colon operator.
One can assume that all entries are positve integers. Delete all pairs where lo(i) > hi(i).
For example:
- lo = [1 5 10]; hi = [3 8 12];
idx = [1 2 3 5 6 7 8 10 11 12]
- lo = [3 5 6 7]; hi = [1 4 6 8];
idx = [6 7 8]
Solution Stats
Problem Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers584
Suggested Problems
-
Given two arrays, find the maximum overlap
1731 Solvers
-
431 Solvers
-
Getting the indices from a vector
11890 Solvers
-
17783 Solvers
-
Matrix multiplication across rows
398 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!