I need to sum the values around the perimeter of a matrix, is there sum function in matlab
2 次查看(过去 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!