18 views (last 30 days)

I assume there is a sum function and attempt the following code:

[x,y] =size(M)

Z = M(x:-1:1, y:-1,1);

Daniel kiracofe
on 11 Nov 2016

For your second sum, instead of sum(A(y,1:1:y)) think you wanted sum(A(x,1:1:y))

Vivek Kumar Chouhan
on 20 Apr 2018

Ibrahim Abouemira
on 19 May 2019

Hello,

Here's a function that performs your required task.

Opportunities for recent engineering grads.

Apply TodayFind the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
## 2 Comments

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/311298-i-need-to-sum-the-values-around-the-perimeter-of-a-matrix-is-there-sum-function-in-matlab#comment_404946

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/311298-i-need-to-sum-the-values-around-the-perimeter-of-a-matrix-is-there-sum-function-in-matlab#comment_404946

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/311298-i-need-to-sum-the-values-around-the-perimeter-of-a-matrix-is-there-sum-function-in-matlab#comment_404947

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/311298-i-need-to-sum-the-values-around-the-perimeter-of-a-matrix-is-there-sum-function-in-matlab#comment_404947

Sign in to comment.