How to fill an array with Nans from 11,000x43 to 32,000x43 to generate a 3D array to be able to concatenate?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm trying to generate a 3D array with 100 different files, however when it tries to concatenate it can't because there are 30 11,000 x 43 files and 70 32,000 x 43 files. I'd like to be able to make them the same size so I can concatenate them.
In addition, I attach a file of each one as an example of the dimensions.
This is my example:
close all; clear all
P = 'D:\2021\datos_cozumel\DatosADCP2\';
S = dir(fullfile(P,'S1*.mat'));
S = natsortfiles(S);
for k = 1:numel(S)
F = fullfile(P,S(k).name);
L = load(F);
v1(k).data = L.Data.Burst_VelBeam1;
end
vb1 = permute(cat(3,v1.data),[1,3,2]);
save('velbeam1_3.mat','vb1')
0 commentaires
Réponses (1)
Walter Roberson
le 4 Août 2022
heights = structfun(@(V)size(V.data,1), v1);
maxheight = max(heights);
paddings = maxheights - heights;
for K = 1 : numel(S)
v1(k).data = [v1(k).data; nan(paddings(K),43)];
end
vb1 = permute(cat(3,v1.data),[1,3,2]);
0 commentaires
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!