row vector summation in pairs without looping
이전 댓글 표시
Hi, I'm a beginner in matlab,I need to compute the sum of all consecutive pairs in my row vector and sum of all those sums computed without looping over.
Ex : [1 2 3 4 5] will give (1+2)+(2+3)+(3+4)+(4+5)
Hope you can help me out. Thanks in advance!
채택된 답변
추가 답변 (1개)
Cris LaPierre
2023년 6월 17일
0 개 추천
Seems like you could create 2 vectors from the given vector, one containing the first number in each summation, and the other containing the second number, and then just add the 2 vectors together.
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!