Created
July 26, 2016 14:31
-
-
Save yolier/652b39d49f43d2bed220d577aa642a89 to your computer and use it in GitHub Desktop.
MAT two HDF5 converter script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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