Thursday, August 13, 2009

fullfile

Build a full filename from parts

Syntax

  • fullfile('dir1','dir2',...,'filename')
    f = fullfile('dir1','dir2',...,'filename')

Description

fullfile(dir1,dir2,...,filename) builds a full filename from the directories and filename specified. This is conceptually equivalent to

  • f = [dir1 dirsep dir2 dirsep ... dirsep filename]

except that care is taken to handle the cases when the directories begin or end with a directory separator.

Examples

To create the full filename from a disk name, directories, and filename,

  • f = fullfile('C:','Applications','matlab','myfun.m')
    f =
    C:\Applications\matlab\myfun.m

The following examples both produce the same result on UNIX, but only the second one works on all platforms.

fullfile(matlabroot,'toolbox/matlab/general/Contents.m') and

fullfile(matlabroot,'toolbox','matlab','general','Contents.m')

No comments:

Post a Comment