element to element sum

24 views (last 30 days)
milad farshbaf
milad farshbaf on 18 Dec 2018
Commented: milad farshbaf on 18 Dec 2018
hi
i have X = [1 5 7 6 9 2 3 1 4 8 6 5]; and i want to do [1+5 5+7 7+6 6+9 ...] how can i do that?
thanks

Accepted Answer

Matt J
Matt J on 18 Dec 2018
X(1:end-1)+X(2:end)

More Answers (1)

Matt J
Matt J on 18 Dec 2018
Edited: Matt J on 18 Dec 2018
conv(X,[1,1],'valid')

Tags

Community Treasure Hunt

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

Start Hunting!