could anyone tell me how to get the sum of an array to a fixed number say 12

1 次查看(过去 30 天)
could anyone tell me how to get the sum of an array to a fixed number say 12

采纳的回答

Torsten
Torsten 2018-1-26
a = 12*a/sum(a)
if a is the array.
Best wishes
Torsten.
  2 个评论
Prabha Kumaresan
Prabha Kumaresan 2018-1-26
ok.But with respect to your answer the sum of array will be fixed to 12,eventhough the answer will not be equal to 12.But what I need is the sum of the array should be 12 while adding the numbers in the array eventhough if it not 12..Could you tell me how to replace the numbers to get the sum of the array to be 12.
Torsten
Torsten 2018-1-29
If you have an array "a" that does not sum to 12, replace it with "12*a/sum(a)". This array will sum to 12.
Best wishes
Torsten.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by