Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
Burke Rosen
Burke Rosen el 7 de Jul. de 2016
Editada: per isakson el 27 de Jul. de 2016
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 comentario
per isakson
per isakson el 27 de Jul. de 2016
Editada: per isakson el 27 de Jul. de 2016
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.

Iniciar sesión para comentar.

Respuestas (0)

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by