How to load partial cell content from a .mat file?
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a mat file which contains a structure. One field contains a cell array. Each cell of this array contains a numeric array. I want to load part of that numeric array without loading the rest of the file into memory. Using h5read, I can load a single field and single numeric array, but I cannot load only part of that array. I believe lower level HDF5 functions should be able to accomplish this, but they are beyond my skill. Has anyone solved this? What I have accomplished is below.
% Load single cell from single field
% (user must supply filename,fieldname, and cell index)
finfo = hdf5info(filename);
grpidx = cellfun(@(x) x(2)~='#',{finfo.GroupHierarchy.Groups.Name});
if numel(grpidx)>2
error('Files with multible variables are not supported.')
end
[~,fn] = cellfun(@fileparts,{finfo.GroupHierarchy.Groups(grpidx).Datasets.Name},'uni',0);
dsidx = ismember(fn,fieldname);
out = h5read(filename,finfo.GroupHierarchy.Groups(grpidx).Datasets(dsidx).Name,cell_idx,1,1);
Thank you,
-Burke Rosen
1 个评论
per isakson
2016-7-27
编辑:per isakson
2016-7-27
Doc says: "Note: hdf5info will be removed in a future version. Use h5info instead."
"Has anyone solved this?"   Yes, something similar on R2013b, but I hesitate to try it again.
To start, mat-version -v7.3 comes with a rather height price both regarding size and speed.
If the "numeric array" is huge and speed is critical - maybe.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 HDF5 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!