Problem in matching a subset of columns of two matrices
Show older comments
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
Accepted Answer
More Answers (1)
Walter Roberson
on 19 Nov 2012
NewT = T(ismember( T(:,[1 2]), R(:,[1 2]), 'rows'), :);
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!