How to cut dimensions of 3d arrays in a cell.

2 ビュー (過去 30 日間)
BN
BN 2019 年 10 月 28 日
コメント済み: Alex Mcaulley 2019 年 10 月 28 日
I have one 34*1 cell.
every array in it have 3 dimensions, all same (720*360*365)
I want to know how to cut all arrays like this: (700:720 * 300:360 * :)
cell.JPG

採用された回答

Yuan Li
Yuan Li 2019 年 10 月 28 日
B = cell(34,1);
for ii = 1:34
B{ii} = precips{ii}(700:720,300:360,:);
end
Then you will get a new cell, each element of the new cell is of size 21*61*365.
  1 件のコメント
BN
BN 2019 年 10 月 28 日
Special thank to both answer

サインインしてコメントする。

その他の回答 (1 件)

Alex Mcaulley
Alex Mcaulley 2019 年 10 月 28 日
Being A your cell array:
newA = arrayfun(@(i) A{i}(700:720,300:360,:),1:numel(A),'uni',0)
  2 件のコメント
BN
BN 2019 年 10 月 28 日
Thank you it's work, but it looks like transpose or something because if you look at the picture before using code all arrays are in a column but after using code all appear in row number 1 and different column. can you help me fix this problem and all arrays store in 1 column (just like firs picture in question)?
thank you
newA.JPG
Alex Mcaulley
Alex Mcaulley 2019 年 10 月 28 日
Then, you can transpose the cell array:
newA = arrayfun(@(i) A{i}(700:720,300:360,:),1:numel(A),'uni',0)'

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by