MATLAB Answers

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

조회 수: 2(최근 30일)
Behzad Navidi
Behzad Navidi 28 Oct 2019
댓글: Alex Mcaulley 28 Oct 2019
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

  댓글 수: 0

로그인 to comment.

채택된 답변

Yuan Li
Yuan Li 28 Oct 2019
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

Behzad Navidi
Behzad Navidi 28 Oct 2019
Special thank to both answer

로그인 to comment.

추가 답변(1개)

Alex Mcaulley
Alex Mcaulley 28 Oct 2019
Being A your cell array:
newA = arrayfun(@(i) A{i}(700:720,300:360,:),1:numel(A),'uni',0)

  댓글 수: 2

Behzad Navidi
Behzad Navidi 28 Oct 2019
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 28 Oct 2019
Then, you can transpose the cell array:
newA = arrayfun(@(i) A{i}(700:720,300:360,:),1:numel(A),'uni',0)'

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by