Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

How to get the index from a matirx

Asked by M@lik Ali on 31 Mar 2013

Hi all

i have two matrix A and B, the size of A is like 10 86 and size of B is 3 86.

actually the matrix B is inside the matrix A.

now what i want is to know the index from matrix A where the vectors of matrix B exist.

like we have a row 1,2,3... 86 in matrix B and same in matrix A as well. I want to get the index of A where this row exist in A. please help me.

0 Comments

M@lik Ali

Tags

Products

No products are associated with this question.

1 Answer

Answer by Wayne King on 31 Mar 2013
Accepted answer
   A = randn(10,10);
   B = A(3:6,:);
   [C,IA,IB] = intersect(A,B,'rows','stable');

IA gives you the row indices in A where B is

1 Comment

M@lik Ali on 31 Mar 2013

Thanks,

Wayne King

Contact us