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

5 次查看(过去 30 天)
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 个评论
Rik
Rik 2018-7-19
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 2018-7-19
The aim is to achieve a signal in this form (attached picture)

请先登录,再进行评论。

回答(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 个评论
Folakemi Omotoye
Folakemi Omotoye 2018-7-19
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matched Filter and Ambiguity Function 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by