expanduser() for Matlab, allowing use of tilde for users

I have created a Matlab/Octave expanduser function that works with GNU Octave and Matlab on Windows and Linux

Python is consistent in that if you use a path starting with tilde ~ you always need the pathlib.Path('~/mypath').expanduser() function to expand this into the user directory. That is, in Python

import pathlib
pathlib.Path('~/Downloads/foo').expanduser()

results in:

OS expanded
Linux /home/joespc/Downloads/foo
Windows C:\users\joespc/Downloads/foo
Mac /Users/joespc/Downloads/foo

Matlab needs expanduser() functionality

as above for functions like h5read(), fitsread()

Leave a Comment