www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/CumulativeSumofEachRowinMatrixExample.m
%% Cumulative Sum of Each Row in Matrix %% % Define a 2-by-3 matrix whose elements correspond to their linear indices. A = [1 3 5; 2 4 6] %% % Find the cumulative sum of the rows of |A|. The element |B(3)| is the sum % of |A(1)| and |A(3)|, while |B(5)| is the sum of |A(1)|, |A(3)|, and % |A(5)|. B = cumsum(A,2)