Remove elements from cell array

3 ビュー (過去 30 日間)
lucksBi
lucksBi 2018 年 1 月 2 日
コメント済み: lucksBi 2018 年 1 月 3 日
Hi all
array1 = {[3,4,5,6];[4,5,7,8];[1,2,6,8]}
toRemove= {{3};{[]};{1,2}}
How can I remove corresponding values in toRemove from array1? Resultant array may look like this
ResultantArray = {[4,5,6];[4,5,7,8];[6,8]}
As there is no element is toRemove{1,2} so [4,5,6,7,8] will remain as it is.
Thanks in anticipation.

採用された回答

James Tursa
James Tursa 2018 年 1 月 2 日
E.g.,
result = cellfun(@(x,y)x(~ismember(x,cell2mat(y))),array1,toRemove,'uni',false);
  1 件のコメント
lucksBi
lucksBi 2018 年 1 月 3 日
Thanks alot

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by