Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想得到cumsum一个向量,但也需要向量的第一个元素来计算自己。一个例子:
cumsum
a = [1 2 3 4 5]
结果需要如下所示:
2 3 6 10 15
想必您已经知道该cumsum功能,所以您没有尝试过吗?:
a = [1 2 3 4 5]; s = cumsum(a); s(1) = s(1)+a(1)
返回
s = 2 3 6 10 15