Computing summation in matlab
조회 수: 2 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (2개)
Wayne King
2013년 2월 22일
편집: Wayne King
2013년 2월 22일
A = ones(144,40);
B = sum(A(:));
or
B = sum(sum(A));
댓글 수: 0
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!