フィルターのクリア

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

1 回表示 (過去 30 日間)
DuckDuck
DuckDuck 2014 年 11 月 19 日
編集済み: Guillaume 2014 年 11 月 19 日
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 Center および File ExchangeString Parsing についてさらに検索

タグ

タグが未入力です。

製品

Community Treasure Hunt

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

Start Hunting!

Translated by