How to find different values of numbers in different matrices?

3 次查看(过去 30 天)
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 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by