필터 지우기
필터 지우기

Problem in matching a subset of columns of two matrices

조회 수: 2 (최근 30일)
Rahman
Rahman 2012년 11월 19일
I have the following matrices:
*********************
Training data set: T
*********************
1 2 0
1 3 1
1 4 1
0 2 0
0 3 0
0 4 1
0 3 1
0 4 0
*********************
Generated Rules: R
*********************
-1 2 0
1 3 1
1 4 1
0 3 0
0 4 0
0 3 1
0 4 1
Problem:
I want to compare the first two columns of matrix R with each row of the matrix T and if matched write all the matching rows of T into a separate matrix. A help is needed.
Thanks in advance.
Rahman Ali

채택된 답변

Rahman
Rahman 2012년 11월 19일
Thanks Walter,
Thanks for the answer but i want to take one row of T each time and compare with all rows of R for match, if row(s) match then write all those into a new matrix. I want to repeat the same process for all rows of T and as a result, I will get more matrices (not one) for the matched rows.
Needs your nice comments.
Thanks Rahman Ali

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 11월 19일
NewT = T(ismember( T(:,[1 2]), R(:,[1 2]), 'rows'), :);

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by