Sum the 'edge' values of a matrix - MATLAB Cody - MATLAB Central

Problem 2240. Sum the 'edge' values of a matrix

Difficulty:Rate

Sum the 'edge' values of an input matrix (the values along the perimeter).

Example

 [1 2 3
  4 5 6
  7 8 9]

Output = 1 + 2 + 3 + 6 + 9 + 8 + 7 + 4 = 40;

Assumption: Input matrix equal or bigger than 3x3.

Solution Stats

48.79% Correct | 51.21% Incorrect
Last Solution submitted on Nov 16, 2025

Problem Comments

Solution Comments

Show comments
Join Cody Contest 2025 — Have Fun and Win Prizes!
...
We’re excited to invite you to Cody Contest 2025! 🎉 Pick a team,...

Problem Recent Solvers380

Suggested Problems

More from this Author2

Problem Tags

Community Treasure Hunt

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

Start Hunting!