How can i load a multiple 1D matlab file and store in single mat file?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
SINAM AJITKUMAR SINGH
el 17 de Dic. de 2018
Comentada: Walter Roberson
el 17 de Dic. de 2018
I have around 400 1D mat files of different size. For example data1 having a size of 1X65000, data2 having size of 1X 45900 and so on... upto data400 having a size of 1X 36000.
how can i store this mat file as Result.mat having file size (400 X minimum length)
1 comentario
Respuesta aceptada
Walter Roberson
el 17 de Dic. de 2018
all_data = zeros(400,0);
for K = 1 : 400
thisfile = sprintf('data%d.mat');
filestruct = load(thisfile);
varnames = fieldnames(filestruct);
firstvarname = varnames{1};
this_data = reshape(filestruct.(firstvarname), 1, []);
if K == 1
all_data = data;
Lall = length(data);
else
L = length(this_data);
if L < Lall
Lall = L;
all_data = all_data(:,1:Lall);
end
all_data(K, :) = this_data(1:Lall);
end
end
0 comentarios
Más respuestas (1)
Mark Sherstan
el 17 de Dic. de 2018
Everything will be in a cell aray but this will do the trick:
for ii = 1:numel(dir('*.mat'))
result{ii} = load(strcat('data',num2str(ii),'.mat'));
end
0 comentarios
Ver también
Categorías
Más información sobre Workspace Variables and MAT Files en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!