Looping through numbers in file and adding first two numbers then next two and so on
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
A = [1 2 3 4 5]
1+2 = 3
2+3 = 5
3+4 = 7
4+5 = 9
How can I loop through an array of numbers like above while storing the number everytime numbers are added? Thank you for any help!
1 Kommentar
Antworten (2)
Andrei Bobrov
am 2 Aug. 2019
Bearbeitet: Andrei Bobrov
am 2 Aug. 2019
conv(A,[1,1],'valid')
or
b = movsum(A,2);
out = b(2:end);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!