matlab sum求和问题
1个回答
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询