Remove elements from cell array

2 vues (au cours des 30 derniers jours)
lucksBi
lucksBi le 2 Jan 2018
Commenté : lucksBi le 3 Jan 2018
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.

Réponse acceptée

James Tursa
James Tursa le 2 Jan 2018
E.g.,
result = cellfun(@(x,y)x(~ismember(x,cell2mat(y))),array1,toRemove,'uni',false);
  1 commentaire
lucksBi
lucksBi le 3 Jan 2018
Thanks alot

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by