How to fill an array with Nans from 11,000x43 to 32,000x43 to generate a 3D array to be able to concatenate?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Walter Roberson
2022-8-4
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!