row vector summation in pairs without looping
Afficher commentaires plus anciens
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!
Réponse acceptée
Plus de réponses (1)
Cris LaPierre
le 17 Juin 2023
0 votes
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.
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!