element to element sum

25 visualizzazioni (ultimi 30 giorni)
milad farshbaf
milad farshbaf il 18 Dic 2018
Commentato: milad farshbaf il 18 Dic 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

Risposta accettata

Matt J
Matt J il 18 Dic 2018
X(1:end-1)+X(2:end)

Più risposte (1)

Matt J
Matt J il 18 Dic 2018
Modificato: Matt J il 18 Dic 2018
conv(X,[1,1],'valid')

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by