columns, none under 5.

2 ビュー (過去 30 日間)
Rasmus
Rasmus 2014 年 4 月 30 日
コメント済み: Rasmus 2014 年 4 月 30 日
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 件のコメント
José-Luis
José-Luis 2014 年 4 月 30 日
Adding them to which columns?
dpb
dpb 2014 年 4 月 30 日
No clue what the above is attempting to describe--give a small starting and ending result; (probably by scaling down the target sum?)

サインインしてコメントする。

採用された回答

José-Luis
José-Luis 2014 年 4 月 30 日
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));
  1 件のコメント
Rasmus
Rasmus 2014 年 4 月 30 日
Thank you!

サインインしてコメントする。

その他の回答 (2 件)

Rasmus
Rasmus 2014 年 4 月 30 日
Sorry for the bad explanation, english is my primary language.
I need the data for some statistiscs,(poisson) which in this case messes my results up,if i have values that are under 5. But i don't want to lose any of the data, i just want to add them so that there are none under 5 left. The length of it doesnt matter, just as long as the sum=200 and there is none under 5.
  3 件のコメント
José-Luis
José-Luis 2014 年 4 月 30 日
編集済み: José-Luis 2014 年 4 月 30 日
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.
Rasmus
Rasmus 2014 年 4 月 30 日
I have an exemple below.
we are instructed to not have values below 5, so i am trying to do that :)
does not matter if its spread over several columns or if its just in one. That i do know how to change myself. I do not know to effectivly add the columns to eachother so that i don't have a single one below 5. the order does not matter as long as it isnt shuffled or anything like that.

サインインしてコメントする。


Rasmus
Rasmus 2014 年 4 月 30 日
like if i have a vector like this.
b=1 1 1 5 6 7 8
i add the ones together, so that i have only values of 5 or above.
b=8 6 7 8

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by