compare and find index of matching elements of two matrices

2 views (last 30 days)
I have two matrices say A=[2.4 2.4] and B=[ 2.4 2.6 3.7 2.4; 3 2.4 4.1 3.6] each element of A compared with each row of B.If the element of A is present in the matrix B, then the index of the element in B should be returned.
In more detail, suppose the first element of A i.e., 2.4 is compared with the first row of B. As it is present in B, the index of the element 2.4 in the B matrix is returned.
  1 Comment
KALYAN ACHARJYA
KALYAN ACHARJYA on 21 Sep 2018
Suppose for the following case, what result you are expecting?
A=[1 2 3 4];
B=[1 2 3 4;5 6 7 8;9 3 11 12];

Sign in to comment.

Answers (1)

KSSV
KSSV on 21 Sep 2018
Read about the function ismember.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!