필터 지우기
필터 지우기

How to load partial cell content from a .mat file?

조회 수: 2 (최근 30일)
Burke Rosen
Burke Rosen 2016년 7월 7일
편집: per isakson 2016년 7월 27일
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
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?" &nbsp 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 CenterFile Exchange에서 HDF5에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by