Problem 646. Getting the row and column location from a matrix
This is a basic MATLAB operation. It is for instructional purposes.
---
You may already know how to get logical indexes from a vector, and to find the location of elements in a vector.
What if you are dealing with a matrix. Often you will want the row and column location of an element, or set of elements. For instance:
[0 1 0 0 0 0]
You might want
row = 1 col = 2
or
[0 1 1 1 0 0]
row = [2 1 1]
col = [1 2 3]
Check out Find to learn to do this.
Given a matrix, M, return the column vectors that represent the row and column indices, r and c, where the given matrix, M is greater than the threshold value, thresh. R and C will be combined into matrix out.
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers286
Suggested Problems
-
Find the sum of all the numbers of the input vector
49132 Solvers
-
Project Euler: Problem 8, Find largest product in a large string of numbers
1100 Solvers
-
Check if number exists in vector
11682 Solvers
-
Create a vector whose elements depend on the previous element
680 Solvers
-
Matlab Basics II - Max & Index of Max
250 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!