フィルターのクリア

How can I check if row matrix B is equal to a row of matrix A?

32 ビュー (過去 30 日間)
laurie
laurie 2015 年 3 月 9 日
コメント済み: Star Strider 2015 年 3 月 9 日
I have a matrix A = [1 2 3; 4 5 6; 7 8 9]
I randomly generate matrix B = [4 5 6]
How can I check if B is a row of A in ONE loop or using NO loops?

採用された回答

Star Strider
Star Strider 2015 年 3 月 9 日
Look Laurie! NO LOOPS!
A = [1 2 3; 4 5 6; 7 8 9];
B = [4 5 6];
[Result,LocResult] = ismember(B,A,'rows')
produces:
Result =
1
LocResult =
2
The ‘Result’ output indicates that there is a match, and ‘LocResult’ that the match is the second row.
  2 件のコメント
laurie
laurie 2015 年 3 月 9 日
wow that's so cool. Thanks!
Star Strider
Star Strider 2015 年 3 月 9 日
My pleasure!
Have fun with MATLAB!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by