Need help with extracting data from n-dimension cell matrix

Hi, I have a 76x102x5 cell matrix. I would like to create a single array of data from each index for n-dimensions. For example,
for k = 1:5
array = cell{1,1,k};
end
output = [ 1 2 3 4 5 ];
so its only the numbers from the same index but in different dimensions.

4 个评论

Me neither but wonder if wouldn't be simpler if OP used cell2mat then proceeded...
What shape of data is stored in each element of the cell array? Is it certain to be consistent?
sorry, if its confusing. Ok let me try to rephrase the question. Lets say, for example, I have a 2x2x3 cell. The data stored in each element is a double, specifically a number between 0-1. I am calculating the correlation coefficient of different sections of an an image between multiple images. So i may have n = 3 pictures, meaning n = 3 dimensions in my cell array.
corrValue(:,:,1) = [1][1]
[1][1]
corrValue(:,:,2) = [0.989][0.999]
[1][0.899]
corrValue(:,:,3) = [0.899][.998]
[0.997][0.899]
I want to extract the data store in each element for the n - dimensions. So for my output. I want to get an array for the (1,1) index,
array = [1 0.989 0.899]; %(1,1) index
The reason being I want to generate a decorrelation curve for each section of the image; therefore, I need to plot the correlation coefficient with respect to the number of images i have taken.

请先登录,再进行评论。

 采纳的回答

I don't fully understand what you are trying, but lets see if this helps you
% This is just to create cell array
ar=rand(2,2,3);
ca=mat2cell(ar,ones(1,2),ones(1,2),ones(1,3));
% Now from above cell array extract double array
da=cell2mat(ca(1,1,:));
da=da(:);

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by