I have created a matrix out of another matrix. I now want to find the index values for those specific numbers in the 2nd matrix FROM the 1st matrix. How would I go about doing that?

20 views (last 30 days)
matrix_1=[11 50;
12 80;
13 120;
14 140;
15 180;
16 210;
17 250;
18 275;
19 325;
20 400;
19 350;
18 300;
17 240;
16 200;
15 190;
14 150;
13 100;
12 75;
10 25]
matrix_2=[11 50;
20 400;
10 25]
I want to create another matrix that lists the index numbers for matrix 2. So it would look something like idx=[1; 10; 19]

Accepted Answer

Jan
Jan on 22 Jan 2019
[ex, index] = ismember(matrix_2, matrix_1, 'rows')

More Answers (0)

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!