Sum per 2 elements in vector
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ann-Lara Aernoudts
el 25 de En. de 2021
Respondida: Abdel
el 18 de Sept. de 2023
Hello,
I am trying to sum my vector by 2 elements.
An example:
I have:
A= [1;2;3;4;5;6]
What I want:
A_new = [3;7;11]
Is there any way to easily code this?
I know one way via a for-loop but I was wondering if there was a more efficient way.
Thanks in advance!
0 comentarios
Respuesta aceptada
Más respuestas (1)
Abdel
el 18 de Sept. de 2023
The sum of the last two elements in (call the result ans6)
0 comentarios
Ver también
Categorías
Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!