Effacer les filtres
Effacer les filtres

Zero padding a 3d structure according to maximum length

12 vues (au cours des 30 derniers jours)
Uerm
Uerm le 3 Nov 2019
Commenté : Uerm le 4 Nov 2019
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?

Réponse acceptée

Turlough Hughes
Turlough Hughes le 3 Nov 2019
Modifié(e) : Turlough Hughes le 3 Nov 2019
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 commentaire
Uerm
Uerm le 4 Nov 2019
Hi, thank you very much. It works brilliantly!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Tags

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by