Sum and Difference across row and column
조회 수: 4 (최근 30일)
이전 댓글 표시
Let say there is square matrix of order n-by-n, and n is odd integer
A = rand(3)
A =
0.4218 0.9595 0.8491
0.9157 0.6557 0.9340
0.7922 0.0357 0.6787
I want to add the entries of second column and take difference of entries in second row to the middle number, i.e.
0.6557+0.9595+0.0357-0.9157-0.9340 = -0.1988
How can I do?
댓글 수: 0
채택된 답변
추가 답변 (1개)
Steven Lord
2020년 5월 8일
You can do this with two simple sum calls and two basic arithmetic operations if you use the inclusion-exclusion principle. Since this sounds like it may be a homework assignment I'm not going to give the complete answer.
댓글 수: 0
참고 항목
카테고리
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!