Effacer les filtres
Effacer les filtres

compare a vector with every cells element and get the missing

2 vues (au cours des 30 derniers jours)
Hamid Salari
Hamid Salari le 7 Août 2017
Commenté : Star Strider le 7 Août 2017
hi . i have a vector V=[1:100] and a C=cell(1-n) with double[] values . how could i get the values in the vector that are not in any element of cell ? and another question : how could i get a vector with repeats of elements in cell ? for example if there are three 2 in the all elements of cell , in my vector index(2) i have 2 ? thanks a lot !.
  2 commentaires
Adam
Adam le 7 Août 2017
Modifié(e) : Adam le 7 Août 2017
Convert C to numeric and use
doc ismember
The second question is basically just a histogram isn't it?
doc histogram
Hamid Salari
Hamid Salari le 7 Août 2017
@Adam i will look into it . thanks .

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 7 Août 2017
Use setdiff inside cellfun:
V = 1:100;
C = {randi(100, 1, 75)}; % Create ‘C’
Out = cellfun(@setdiff, {V}, C, 'Uni',0); % Use ‘setdiff’
Result = [Out{:}] % Dsiplay Result (Not Necessary For The Code)
  4 commentaires
Hamid Salari
Hamid Salari le 7 Août 2017
@Star Strider. i got the idea behind it . thanks . my current cell is 1*12.
Star Strider
Star Strider le 7 Août 2017
My pleasure.
My code should work with it as written.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by