How can I make a set of numbers and add numbers to it later?
Afficher commentaires plus anciens
I want to create a set of numbers, like for example all odd numbers divisible by 3: S = {3, 9, 15} etc. I have thought of creating a vector, but in the calculation matlab doesn't see a vector as a set of numbers. Later on in my calculation I want to add even more numbers to the set S, for example I want to add the numbers {21, 27}. I have no clue how to fix this in matlab, the only thing I thought of was, as I said, creating a vector but that option doesn't seem to work for me. After creating a set of numbers I want to pick the elements out of the set and check whether they are divisible by 6 for example. But as soon as I know how to make such a set, my expectation is that picking some element out of it would be a matter of trial and error.
Is there an option in matlab to create a set of self chosen numbers, and add later even more numbers to the same set and make some more calculations with the expanded set after all? Thanks in advance.
2 commentaires
Azzi Abdelmalek
le 25 Déc 2013
I think you can make your question more clear and breve. For example, what do you mean by: matlab doesn't see a vector as a set of numbers. Give a short example and show what are you expecting as result.
Maik Petersen
le 25 Déc 2013
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 25 Déc 2013
if ismember(8, numset)
disp('yes')
end
Catégories
En savoir plus sur Performance and Memory dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!