Delete part of the third dimension for arrays that store in the cell

1 次查看(过去 30 天)
Hello all,
If I had just one 3d array I know I can use:
new = 3darray(:,:,2:end)
In order to delete the first number of the third dimension.
But as I have a lot of arrays that stored in the cell, I don't know how to do it automatically. Here what I tried so far:
for i= 1:numel(tmax) %if tmax is my cell that 3d arrays stored in it
b = tmax(i,1);
b = b(:,:,2:end);
end
But it doesn't work correctly and result me b = 1x1x0 cell
I'm sorry but as my data (even when I tried to cut just part of it) are too large to attach I just insert a picture here:
Thank you all

采纳的回答

Sindar
Sindar 2020-3-24
编辑:Sindar 2020-3-24
to access the data in cells (rather than the cells themselves) and to store data in a new cell array, use {}
for i= 1:numel(tmax)
% iterates through every cell of tmax, regardless of dimensions
temp = tmax{i};
b{i} = temp(:,:,2:end);
end
% shapes b (originally 1D) to match tmax
b = reshape(b,size(tmax));

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Cell Arrays 的更多信息

标签

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by