Sum of adjacent elements in a vector - MATLAB Cody - MATLAB Central

Problem 44416. Sum of adjacent elements in a vector

Difficulty:Rate

Given a vector v, return a vector s containting the sum of every two adjacent elements in the vector.

Every element s(i) contains the sum of v(i) and v(i+1).

Example:

 v = [1, 2, 4, 4, 5, 8]
 s = [3, 6, 8, 9, 13]

Solution Stats

25.48% Correct | 74.52% Incorrect
Last Solution submitted on Mar 06, 2025

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers575

Suggested Problems

More from this Author25

Problem Tags

Community Treasure Hunt

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

Start Hunting!
Go to top of page