%% Cumulative Product of Each Column in Matrix
% Define a 3-by-3 matrix whose elements correspond to their linear indices.

A = [1 4 7; 2 5 8; 3 6 9]

%
% Find the cumulative product of the columns of A. The element B(5) is the product of A(4) and A(5), while B(9) is the product of A(7) , A(8), and A(9).

B = cumprod(A)

% Copyright 2012 The MathWorks, Inc.