Looping through numbers in file and adding first two numbers then next two and so on
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Andrei Bobrov
2019-8-2
编辑:Andrei Bobrov
2019-8-2
conv(A,[1,1],'valid')
or
b = movsum(A,2);
out = b(2:end);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!