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
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!