Function to convert relative paths to absolute paths?

matlab

Solution

`fullfile(pwd, relative_path)` converts a relative to a absolute path.

Problem

I've spent quite some time to no avail looking for a built-in MATLAB function to convert relative file paths to absolute file paths (portably). Is there one? I'm looking for something preferably "built-in" (i.e. available somewhere in the MATLAB distribution, including one of its toolboxes). Even a "package-private" function would be acceptable, as long as I can examine the source code of function. Second best would be a third-party function, as long as it comes with a decent test suite. I am not looking for a function written in response to this question.1 Absent any of the above, even a function to test (portably) whether a path is absolute or not would do (with the same conditions as before: either a "built-in" function or a third-party function with a test suite). 1 The difficulty with implementing such a function is not writing the function itself, but rather writing a sufficiently complete test suite for it (and, of course, making sure that the function passes all the tests!).

Original source