How to load partial cell content from a .mat file?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
per isakson
le 27 Juil 2016
Modifié(e) : per isakson
le 27 Juil 2016
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.
Réponses (0)
Voir également
Catégories
En savoir plus sur HDF5 dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!