Summing the elements of an array while maintaining its size

조회 수: 1 (최근 30일)
Lev Mihailov
Lev Mihailov 2022년 2월 17일
편집: KSSV 2022년 2월 17일
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