Effacer les filtres
Effacer les filtres

Take percentage of a data set

4 vues (au cours des 30 derniers jours)
jgillis16
jgillis16 le 28 Juil 2015
Commenté : jgillis16 le 29 Juil 2015
I need to take 17.65% of a 2016x1 double array (meaning I only want 17.65% of the data in that array).
What would the code for this look like?
Thanks!
  1 commentaire
Azzi Abdelmalek
Azzi Abdelmalek le 28 Juil 2015
If a=4; what is 17.65% of a?

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 29 Juil 2015
num_to_fetch = round(17.65 / 100 * length(YourVector));
your_subset = YourVector(randperm(length(YourVector), num_to_fetch));
  1 commentaire
jgillis16
jgillis16 le 29 Juil 2015
Thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Types 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