GNU Octave understands that
~ tilde is the user’s home directory on any operating system, even Windows.
Matlab does not consistently understand
~ as the user home directory.
We created expanduser.m that works on Linux, Mac and Windows. It returns the absolute path of the user home directory, for example: