how to sum all elements of one vector?

78 次查看(过去 30 天)
fathi
fathi 2017-10-10
编辑: Jan 2017-10-10
hi every one ; how to sum elements of one vector ; Ex: if C =[ 2;3;4;5] .. D = the summation of all elements in C , D = 14. So how can i get D??... by the way how can i divide each element from C over D .. so C will be = [0.1428 ;0.2142; 0.2857; 0.3571] . thanks

回答(1 个)

KL
KL 2017-10-10
编辑:KL 2017-10-10
  3 个评论
fathi
fathi 2017-10-10
thanks, mr KL, but the summation of C supposes to be 14 . just one number. if I use D = sum(C); D= 0.6196 0.8000 0.6706 0.5765.
Jan
Jan 2017-10-10
编辑:Jan 2017-10-10
Then you must have redefined the function "sum" by a variable. Try this again:
clear sum
C = [2;3;4;5]
D = sum(C)
E = C ./ D

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Range and Doppler Estimation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by