matlab中sum函数对矩阵的求和总结
A= [1, 2 ,3 ,4, 5;
1, 2, 3, 4, 5];
a=sum(A)
>>a= [2 4 6 8 10]
sum(A(1:t,:),1)
b=sum(A,2) %对整个矩阵按行求和
>>b=[15;15];
d=sum(A(:,1:3),2)
>>d = [6;6]
c=sum(A(:)) %整个矩阵整体求和
>>c =30
A(:,1)是求矩阵的第一列
a=sum(A)
>>a= [2 4 6 8 10]
sum(A(1:t,:),1)
b=sum(A,2) %对整个矩阵按行求和
>>b=[15;15];
d=sum(A(:,1:3),2)
>>d = [6;6]
c=sum(A(:)) %整个矩阵整体求和
>>c =30