Zero padding a 3d structure according to maximum length

5 ビュー (過去 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
  1 件のコメント
Uerm
Uerm 2019 年 11 月 4 日
Hi, thank you very much. It works brilliantly!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet 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