I need help with a problem. I want to find the position of a specific data set in a matrix, and I do not find a function that really works. An example: In the matrix A = [1 3 4 7 10 3 7 9 19 10 1 5 8 3 7] I want to find the position of the array (3, 7), which will be the positions (7, 15). Any ideas?

1 Comment

madhan ravi
madhan ravi on 9 Oct 2018
Edited: madhan ravi on 9 Oct 2018
What do you mean (3,7) & (7,15) ? Give your expected output as an example.

Sign in to comment.

 Accepted Answer

Jan
Jan on 9 Oct 2018
Edited: Jan on 9 Oct 2018
Maybe you mean:
A = [1 3 4 7 10 3 7 9 19 10 1 5 8 3 7];
P = [3, 7];
index = strfind(A, P)
In opposite to the name, strfind does not operate on strings or char vectors only.
This replies [6, 14], so maybe you want to add 1 to the result.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!