www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/CumulativeSumofEachColumninMatrixExample.m
%% Cumulative Sum 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 sum of the columns of |A|. The element |B(5)| is the % sum of |A(4)| and |A(5)|, while |B(9)| is the sum of |A(7)|, |A(8)|, and % |A(9)|. B = cumsum(A)