Effacer les filtres
Effacer les filtres

Compare elements of two cell vectors

4 vues (au cours des 30 derniers jours)
Christian F.
Christian F. le 10 Mai 2012
Hi,
I have two cell vectors of different lengths, containing both numbers and numbers/characters.
Now, I want to delete all elements of vector A, which are not in vector B.
Best, Chris
  1 commentaire
per isakson
per isakson le 10 Mai 2012
Did you search the FEX (File Exchange)? Did you experiment with the function, ismember?

Connectez-vous pour commenter.

Réponse acceptée

Christian F.
Christian F. le 10 Mai 2012
I found a solution.
First I converted all elements of both cell arrays to strings with this code I found:
numIndex = cellfun('isclass', B, 'double');
tmpStr = sprintf('%g;', B{numIndex});
B(numIndex) = dataread('string', tmpStr, '%s', 'delimiter', ';');
Then I compared the arrays with
ismember(A,B)
Thanks all anyway.

Plus de réponses (0)

Catégories

En savoir plus sur Cell Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by