www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ReverseCumulativeSumExample.m

    %% Reverse Cumulative Sum  

%% 
% Create a 3-by-3 matrix of random integers between 1 and 10. 
rng default;
A = randi([1,10],3)  

%% 
% Calculate the cumulative sum along the rows. Specify the |'reverse'| option
% to work from right to left in each row. The result is the same size as |A|. 
B = cumsum(A,2,'reverse')