フィルターのクリア

How to Remove the values that exist in a cell from another cell.

3 ビュー (過去 30 日間)
Alexandros Samp
Alexandros Samp 2016 年 9 月 3 日
コメント済み: Alexandros Samp 2016 年 9 月 4 日
For example if i have a Cell F{} with [4 2 3 6 8 7] and another Cell G{} [3 4 6] and i want to remove the values from F that exist in G. So it will be like F{}=[2 8 7].

採用された回答

Andrei Bobrov
Andrei Bobrov 2016 年 9 月 3 日
ii = strfind(Head{4},Hf{3});
Head{4}(bsxfun(@plus,ii(2:end),(0:numel(Hf{3})-1)')) = [];
  1 件のコメント
Alexandros Samp
Alexandros Samp 2016 年 9 月 4 日
Thank you.! How can i write this function if i want the next element, for example in Head{5} i need to remove Hf{3} and Hf{4} and so..

サインインしてコメントする。

その他の回答 (1 件)

KSSV
KSSV 2016 年 9 月 3 日
編集済み: KSSV 2016 年 9 月 3 日
setdiff(F{1},G{1})
Calculate the difference between to arrays..
  3 件のコメント
KSSV
KSSV 2016 年 9 月 3 日
F{1} = setdiff(F{1},G{1})
Alexandros Samp
Alexandros Samp 2016 年 9 月 3 日
Head{4}
ans =
Columns 1 through 4
0.0032 0.0032 0.0142 0.0039
Columns 5 through 8
0.0019 0.0142 0.0039 0.0019
Hf{3}
ans =
0.0142 0.0039 0.0019
I would like to remove the values from Head that exist in the Hf{3}, so the New Head{4} would be 0.0032 0.0032 0.0142 0.0039 0.0019.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by