how to remove rows from an array containig elements from another array

1 次查看(过去 30 天)
Suppose i have a matrix of
a=[1,2;
1,3;
1,4;
2,12;
2,15;
5,7;
5,8;
6,98;
6,99;
7,8;
7,9;
7,11;
9,14;
9,16;
12,18;
14,20;
20,35;
98,102;
99,204;
204,300];
I want to remove rows containing elements from array b, do some manipulations than remove elements of c do smth and than d.
b=[1,2,3,4,12,15,18]
c=[5,7,8,9,14,16,20,35]
d=[6,98,99,102,204,300]
is there a fast and wasy way to do that with built in matlab functions

采纳的回答

Guillaume
Guillaume 2014-11-19
编辑:Guillaume 2014-11-19
Use the negation of ismember to get the elements of a column of a that are not in b. If you want to do that for both columns of a, you have to call ismember twice.
col1notinb = ~ismember(a(:, 1), b);
col2notinb = ~ismember(a(:, 2), b);
awithoutb = a(col1notinb & col2notinb, :);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 String Parsing 的更多信息

标签

尚未输入任何标签。

产品

Community Treasure Hunt

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

Start Hunting!

Translated by