Computing summation in matlab
古いコメントを表示
I have a matrix let say A=ones(144,40);
and I want to compute the summation with lower limit is 1 and upper limit is dimension of A like 144*40=5760.
How can I compute it using symsum or sum other function?
回答 (2 件)
Wayne King
2013 年 2 月 22 日
編集済み: Wayne King
2013 年 2 月 22 日
A = ones(144,40);
B = sum(A(:));
or
B = sum(sum(A));
Mark Whirdy
2013 年 2 月 22 日
編集済み: Mark Whirdy
2013 年 2 月 22 日
If Wayne is right and you're talking about limits to the summation, is it that you want to control these limits as parameters, or you simply want to always sum over every element (1:(size(A,1)*size(A,2))) of the matrix?
Wayne provides the latter solution, a solution to the former might be
limitSum = @(X,l_b,u_b)(sum(X(l_b:u_b))); % define amonymous function
A = ones(144,40);
limitSum(A,1,size(A,1)*size(A,2)); % apply function to A
5 件のコメント
Wayne King
2013 年 2 月 22 日
I think the OP is just referring to the limits of the summation as in
\sum_{n=1}^{N} x[n]
Algorithms Analyst
2013 年 2 月 22 日
Algorithms Analyst
2013 年 2 月 22 日
Wayne King
2013 年 2 月 22 日
did you look at my answer? that sums all the elements in the matrix
Mark Whirdy
2013 年 2 月 22 日
then its just a sum as Wayne said
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!