multiply along

~EDITED'
Hi there, I have a long matrix 1000 x 34 want to do the cumulative multiplication left to right to give a 1000 x 1 matrix then the sum of the multiplication going downwards. So like a sum function but multiplying each element going sideways then downwards.
EDITED THIS ANSWER HAS BEEN ANSWERED but need a follow on answer...

 采纳的回答

sum(cumprod(A))

2 个评论

What if their are zeros. Is there a line code to change all zeros to 1s?
T = A;
T(T==0) = 1;
sum(cumprod(T))

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2012-6-6

0 个投票

If the numbers are strictly positive, you could log() and cumsum() and exp() the result.

类别

在 帮助中心 和 File Exchange 中查找有关 Entering Commands 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by