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!