How can I check if row matrix B is equal to a row of matrix A?
    11 ビュー (過去 30 日間)
  
       古いコメントを表示
    
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?
0 件のコメント
採用された回答
  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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

