Task:
Write a function that takes a vector X and returns the alternating sum of X:
X(1)-X(2)+X(3)-X(4)+...
Example:
for vector X=[1 2 3] the function should return 1-2+3=2.
Solution Stats
Solution Comments
Show comments
Loading...
Problem Recent Solvers50
Suggested Problems
-
Sum of diagonal of a square matrix
1645 Solvers
-
Reverse the elements of an array
1145 Solvers
-
Given a matrix, swap the 2nd & 3rd columns
1284 Solvers
-
Side of an equilateral triangle
7207 Solvers
-
390 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!