Zero padding a 3d structure according to maximum length

조회 수: 10 (최근 30일)
Uerm
Uerm 2019년 11월 3일
댓글: Uerm 2019년 11월 4일
Hi,
I have a 1x24 cell containing tensors (3d structures) with sizes 90xYxZ. I want to pad zeros along the second dimension (Y) so that all the tensors have the same length as the maximum Y value in the cell. How can I do that?

채택된 답변

Turlough Hughes
Turlough Hughes 2019년 11월 3일
편집: Turlough Hughes 2019년 11월 3일
Hi Uerm,
Lets call your data mycellarray. You can padd the second dimension of all tensors to have the same length as the one with the longest Y dimension as follows:
[~,b,~]=cellfun(@size,mycellarray) % get size of Y on each tensor
idx_padd=max(b)-b; % find difference from max Y dimension
for ii=1:length(mycellarray)
mycellarray{1,ii}= padarray(mycellarray{1,ii},[0 idx_padd(ii) 0],0,'post'); %padd
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by