Effacer les filtres
Effacer les filtres

creating a variable to use for grouping data

1 vue (au cours des 30 derniers jours)
Rabeya
Rabeya le 20 Avr 2012
I want to create a variable (a column vector) with a specific length (8000), containing values 1 to 10 randomly assigned and with a specific average repetition of each number (say 800). How to do this?

Réponse acceptée

Walter Roberson
Walter Roberson le 20 Avr 2012
If the number of repetitions is to be exact:
t = repmat(1:10.', 800, 1);
t(randperm(length(t)))
If the repetitions need not be exact:
1 + floor(10 * rand(8000,1))
  2 commentaires
Rabeya
Rabeya le 20 Avr 2012
Very impressive!
Walter Roberson
Walter Roberson le 20 Avr 2012
Opps, I had an extra layer of repmat() on the first solution! I have edited.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Time Series Events dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by