I need to sum the values around the perimeter of a matrix, is there sum function in matlab
조회 수: 1 (최근 30일)
이전 댓글 표시
I assume there is a sum function and attempt the following code:
[x,y] =size(M)
Z = M(x:-1:1, y:-1,1);
답변 (2개)
Daniel kiracofe
2016년 11월 11일
For your second sum, instead of sum(A(y,1:1:y)) think you wanted sum(A(x,1:1:y))
댓글 수: 1
Vivek Kumar Chouhan
2018년 4월 20일
this code works good for calculating perimeter of matrix of order higher than 2*2 but doesn't work for 2*2 matrix
참고 항목
카테고리
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!