How to find different values of numbers in different matrices?

1 回表示 (過去 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 Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by