How to find different values of numbers in different matrices?

조회 수: 2 (최근 30일)
Matias
Matias 2016년 11월 28일
답변: Preethi 2016년 11월 28일
Hello everybody. First of all, sorry for my english. I have a problem finding different values in some matrices. For example I have the matrices:
A=[1 2 3;7 6 7;0 5 6] B=[5 4 6;1 2 3;9 0 0] C=[4 5 4;1 2 3;7 3 2]
What I want to do is to search if the first row of A exists in B, and if it exists, to search for it in the next matrix, in this case C, and obtain the number of row in which they appear in each matrix. In my case I have a lot of matrices, not just 3, so I would like to do it with a for loop. I'm sure this can be done but I couldn't find a way to do it properly.
Thanks in advance..

답변 (1개)

Preethi
Preethi 2016년 11월 28일
hi,
you can use ismember() function. if the row exists the output will be one, else zero
ismember(A(1,:),B,'rows')

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by