how can i get the cumsum of a 3D matrix.

4 views (last 30 days)
i have a 3-D matrix.I want to use the cumsum algorithm to plot all the matrix as a signal. i have the following code
m=zeros(10,10,30); %define 3-D 10 by 10 by 30 matrix
n=30; %number of matrix
for k=1:n
t=linspace(0,1.0,n); %specify the value an element will take in each iteration
m(3,3,k) = t(k); %the 3rd row and 3rd column in each matrix will have the value of t
disp(m(:,:,k))
end
for k=1:n
a=cusum(m(:,:,k))
plot (a)
hold on
end
  10 Comments
Rik
Rik on 19 Jul 2018
Could you describe your intended resulting plot by describing how the the x and y values of each point in the plot should result from your matrix?
Folakemi Omotoye
Folakemi Omotoye on 19 Jul 2018
The aim is to achieve a signal in this form (attached picture)

Sign in to comment.

Answers (1)

Constantino Carlos Reyes-Aldasoro
To be able to properly help you, the problem needs to be well defined. As context, what you obtain with cumsum is an accummulation of values along one dimension of the data. So you can find this accummulation along any dimension you want. Think of it with a 1D matrix, many values and they accummulate within the dimension. If you have a probability distribution, the last value of the cumsum should always be 1.
If what you want is to find a projection, or in proper statistical terms, a marginal distribution, then you need to use sum( , dim) along the dimension of interest.
  1 Comment
Folakemi Omotoye
Folakemi Omotoye on 19 Jul 2018
I tried the cumsum and i specified the dimension but there was error saying dimensions must be the same. the aim is to achieve a signal in this form(see pic attached) of the changing pixels

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!