Deleting rows with identical values in determined columns of two matrices.
1 回表示 (過去 30 日間)
古いコメントを表示
Hello. I have two large matrices with the next dimensions
Matrix a = 6700 x 8.
Matrix b= 388000 x 8
As a note, I would like to say that both "matrix a" and "matrix b", column 1 to column 4 are time data (year, month, day, hour), and from column 5 to column 8 are data measurements.
It is required a routine which compares column 1 to column 4 from "matrix a" with column 1 to column 4 from "matrix b", finds the elements repeated in column 1, column 2, column 3 and column 4 of both matrices, and finally deletes all this rows only in "matrix b", generating a "new matrix b". Also is desirable that the "new matrix b" has an ascending order taking into account only column 1 to column 4, due to this columns are the time data.
For instance:
Matrix a = [2009,10,2,2,0,0,0,0; 2009,10,2,2,0,0,0,0; 2009,10,9,5,0,0,0,0]
Matrix b = [2012,10,9,5,1,2,3,4; 2009,10,9,5,3,9,7,1; 2012,10,9,5,1,2,3,4]
New Matrix b => [2012,10,9,5,1,2,3,4; 2012,10,9,5,1,2,3,4]
In this example, "matrix b" has in the second row, the same elements that are present in the third row of "matrix a", only taking into account column 1 to column 4 of both matrices (the data repeated are 2009,10,9,5). For this reason, the entire second row of "matrix b" is eliminated in the "new matrix b".
I want to implement this kind of solution to my whole "matrix b", which has dimensions of 388000 x 8.
Thanks in advance.
0 件のコメント
採用された回答
Azzi Abdelmalek
2015 年 12 月 28 日
a = [2009,10,2,2,0,0,0,0; 2009,10,2,2,0,0,0,0; 2009,10,9,5,0,0,0,0]
b = [2012,10,9,5,1,2,3,4; 2009,10,9,5,3,9,7,1; 2012,10,9,5,1,2,3,4]
out=b(~ismember(b(:,1:4),a(:,1:4),'rows'),:)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!