Summing the elements of an array while maintaining its size

1 次查看(过去 30 天)
There is an array of data, I need to sum it while maintaining the length of the array
a=[0 2 2 6]
Ineed=[0 2 4 10]
there are some functions for this or it will be necessary to write a cycle, I will be glad for any help

回答(1 个)

KSSV
KSSV 2022-2-17
编辑:KSSV 2022-2-17
a=[0 2 2 6];
Ineed=cumsum(a)
Ineed = 1×4
0 2 4 10

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by