Skip to content

Instantly share code, notes, and snippets.

@yolier
Created July 26, 2016 14:31
Show Gist options
  • Select an option

  • Save yolier/652b39d49f43d2bed220d577aa642a89 to your computer and use it in GitHub Desktop.

Select an option

Save yolier/652b39d49f43d2bed220d577aa642a89 to your computer and use it in GitHub Desktop.
MAT two HDF5 converter script.
function MAT_2_HDF5(filepath)
vars = load(filepath);
expression = '[\\/\.]';
splitPath = regexp(filepath,expression,'split');
splitPathChar = char(splitPath);
matFilename = strtrim(splitPathChar(end-1,:));
h5Filename = sprintf('%s.h5', matFilename);
for f = fieldnames(vars)'
sz = size(vars.(f{1}));
dsName = sprintf('/%s', f{1});
h5create(h5Filename, dsName, sz)
h5write(h5Filename, dsName, vars.(f{1}))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment