Delete rows from matrix that contain values that correspond to values from a separate variable vector
1 回表示 (過去 30 日間)
古いコメントを表示
Hi,
I wish to remove rows from a matrix A [n x 2] that contains any value from another vector B [1 x n] in its first column. The values in vector B change depending on my problem, I am therefore looking for a solution that can read the values in the B vector and apply the modification automatically to the A matrix.
An example B vector is shown below:
B = [2, 3, 5, 8, 10]
Along with an example A matrix:
A = [ 1 2;
2 3;
2 4;
3 1;
3 4;
4 2;
4 9;
5 1;
5 7;
6 2;
6 3;
6 4;
8 2;
8 9;
9 1;
9 6;
10 6]
The desired output matrix Z [n x 2] would be as follows:
Z = [ 1 2;
4 2;
4 9;
6 2;
6 3;
6 4;
9 1;
9 6]
Any help would be appreciated. I am using this solution as part of a meshing algorithm that I am developing, where matrix Z forms the connectivity between nodes.
Thanks in advance, Sam
0 件のコメント
採用された回答
その他の回答 (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!