Search code examples
matlabfilepath

How to pass a cell array to fullfile


How do I pass a cell array like

pathParts = {'D:', 'foo', 'matic'}

to fullfile to obtain a complete path (i.e. D:\foo\matic)?


Solution

  • As follows:

    fullfile(pathParts{:})
    

    By colon indexing of a cell array, MATLAB will return a comma separated list. This you can then easily pass to other functions.