필터 지우기
필터 지우기

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

조회 수: 17 (최근 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.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by