Importing data to 3D array in matlab
7 次查看(过去 30 天)
显示 更早的评论
I'm trying to import many data files that contain x and y (wavenumber/intensity) data into a 3D array. Each data file has a different number of x and y data points. I'm having trouble getting each data set imported into my 3D array since they are all different sizes and I get an error message that the size of the left side doesn't match the right side after the first iteration in the for loop. Any help on getting it to work would be appreciated!
dir = "../Data Dump/Process Data/";
file_type = '*.asc';
%%%create datastore
Datastore = datastore(dir+file_type,"ReadSize","file","VariableNames",["wavenumber","intensity","rand"]);
reset(Datastore)
nfiles = length(Datastore.Files);
file_names = erase(Datastore.Files,dir)';
for n =1:nfiles
T = importdata(file_names{n});
Data(:,:,n) = [T(:,1) T(:,2)];
end
采纳的回答
Voss
2024-3-2
Since each file has a different number of x,y, it'll be more convenient to use a cell array:
Data = cell(1,nfiles);
for n = 1:nfiles
T = importdata(file_names{n});
Data{n} = T(:,[1 2]);
end
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Biological and Health Sciences 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!