gistlib
main.m x = [1, 2, 4]; cumsum(x) % Output: 1 3 7 sum(x) % Output: 7 prod(x) % Output: 8 cumprod(x) % Output: 1 2 8 ``` The `cumsum` function computes the cumulative sum of elements of an input array. It returns an array where each element is the sum of itself and all previous elements. The `sum` function computes the sum of elements of an input array. The `prod` function computes the product of elements of an input array. The `cumprod` function computes the cumulative product of elements of an input array. It returns an array where each element is the product of itself and all previous elements. 748 chars15 lines
x = [1, 2, 4]; cumsum(x) % Output: 1 3 7 sum(x) % Output: 7 prod(x) % Output: 8 cumprod(x) % Output: 1 2 8 ``` The `cumsum` function computes the cumulative sum of elements of an input array. It returns an array where each element is the sum of itself and all previous elements. The `sum` function computes the sum of elements of an input array. The `prod` function computes the product of elements of an input array. The `cumprod` function computes the cumulative product of elements of an input array. It returns an array where each element is the product of itself and all previous elements.
gistlibby LogSnag