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
0 个评论
采纳的回答
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));
1 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!