matlab sum求和问题

 我来答
zxkjack123
2012-08-07 · TA获得超过584个赞
知道小有建树答主
回答量:416
采纳率:0%
帮助的人:343万
展开全部
matlab中的求和对于常数和一维向量是一样的,对矩阵是对其每一列求和。具体参见函数用法说明
sum Sum of elements.
S = sum(X) is the sum of the elements of the vector X. If
X is a matrix, S is a row vector with the sum over each
column. For N-D arrays, sum(X) operates along the first
non-singleton dimension.
If X is floating point, that is double or single, S is
accumulated natively, that is in the same class as X,
and S has the same class as X. If X is not floating point,
S is accumulated in double and S has class double.

S = sum(X,DIM) sums along the dimension DIM.

S = sum(X,'double') and S = sum(X,DIM,'double') accumulate
S in double and S has class double, even if X is single.

S = sum(X,'native') and S = sum(X,DIM,'native') accumulate
S natively and S has the same class as X.

Examples:
If X = [0 1 2
3 4 5]

then sum(X,1) is [3 5 7] and sum(X,2) is [ 3
12];

If X = int8(1:20) then sum(X) accumulates in double and the
result is double(210) while sum(X,'native') accumulates in
int8, but overflows and saturates to int8(127).

See also prod, cumsum, diff, accumarray, isfloat.
Overloaded methods:
codistributed/sum
timeseries/sum
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式