columns, none under 5.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
hey guys!
I have a question
a= 1 0 0 1 1 0 2 0 2 0 3 3 4 1 4 0 7 1 7 2 9 1 6 3 7 2 10 1 10 3 8 1 10 6 13 5 8 3 13 0 7 4 5 5 3 0 2 1 2 0 2 1 3 0 1 2 1 0 0 0 2 0 1
How would be the easiest way to make sure there is no numbers under 5? I don't want to filter the numbers under 5 away, but keeping them in the vector by adding them to other columns.
so that the sum(a)= 200, which is the total now.
2 commentaires
dpb
le 30 Avr 2014
No clue what the above is attempting to describe--give a small starting and ending result; (probably by scaling down the target sum?)
Réponse acceptée
José-Luis
le 30 Avr 2014
One of many, many possible ways:
a = [1 0 0 1 1 0 2 0 2 0 3 3 4 1 4 0 7 1 7 2 ...
9 1 6 3 7 2 10 1 10 3 8 1 10 6 13 5 8 3 ...
13 0 7 4 5 5 3 0 2 1 2 0 2 1 3 0 1 2 1 0 ...
0 0 2 0 1];
your_mat = a(a > 5);
your_mat(1) = your_mat(1) + sum(a(a<=5));
Plus de réponses (2)
Rasmus
le 30 Avr 2014
3 commentaires
José-Luis
le 30 Avr 2014
Modifié(e) : José-Luis
le 30 Avr 2014
That still does not explain what you want. Would like the data to be spread over several columns or a single one? There is effectively, infinitely many ways to answer your question. Furthermore, if you want to do statistics and just change your data like that not only are you introducing bias but completely changing your distribution.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!