Problem 647. Getting the absolute index from a matrix
This is a basic MATLAB operation. It is for instructional purposes.
---
You may already know how to get the row and column index from a matrix, and the logical indexing technique but there is another way to reference specific elements in a matrix.
Absolute indexing refers to specific elements with a single scalar rather than two (row and column). The upper left entry is value 1, the lower right is the highest value. MATLAB is column major, so you count down the rows in a specific column first, moving right as needed until you reach the end.
Indexing into a vector is really using this kind of indexing, but it is more natural feeling.
Use Find.
Given a matrix M, return the absolute indices where M is greater than scalar, LB (Lower Bound) and less than UB (Upper Bound). (See Binary comparison to satisfy two conditions)
Solution Stats
Problem Comments
-
1 Comment
The test suite gives an answer.
Solution Comments
Show commentsProblem Recent Solvers248
Suggested Problems
-
Back to basics 6 - Column Vector
1075 Solvers
-
Given a window, how many subsets of a vector sum positive
857 Solvers
-
Matrix which contains the values of an other matrix A at the given locations.
229 Solvers
-
Check that number is whole number
4558 Solvers
-
Back to Basics - Find no. of elements in a matrix?
312 Solvers
More from this Author51
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!