matlab求和函数是什么,matlab求和函数使用教程
sum
Sum of array elements
Syntax
B = sum(A)
B = sum(A,dim)
B = sum(..., 'double')
B = sum(..., dim,'double')
B = sum(..., 'native')
B = sum(..., dim,'native')
Examples
The magic square of order 3 is
M = magic(3) M = 8 1 6 3 5 7 4 9 2This is called a magic square because the sums of the elements in each column are the same.
sum(M) = 15 15 15
注意
如果你的矩阵数据类型是cell等无法进行直接求和的数据类型,需要对数据进行预处理
sum(x)以矩阵x的每一列为对象,对一列内的数字求和。
sum(x,2)以矩阵x的每一行为对象,对一行内的数字求和。
网友咨询:请问sum(x.^2)是什么意思呢?
表示先将x的元素分别求平方,再对其列求和。
本文地址:百科问答频道 https://www.neebe.cn/wenda/886649.html,易企推百科一个免费的知识分享平台,本站部分文章来网络分享,本着互联网分享的精神,如有涉及到您的权益,请联系我们删除,谢谢!