| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
[pathstr, name, ext, versn] = fileparts(filename)
[pathstr, name, ext, versn] = fileparts(filename) returns the path name, file name, extension, and version for the specified file. filename is a string enclosed in single quotes. The returned ext field contains a dot (.) before the file extension.
The fileparts function is platform dependent.
You can reconstruct the file from the parts using:
fullfile(pathstr,[name ext])
Return the pieces of a file specification string to the separate string outputs pathstr, name, and ext. The full file specification is
file = '\home\user4\matlab\classpath.txt';
The character used to separate the segments of a path name is dependent on the operating system you are currently running on. In this example, it is the backslash (\) character, which is used as a separator on Microsoft Windows platforms. For portability, use the filesep function to insert the correct separator character:
sep = filesep; file = ['' sep 'home' sep 'user4' sep 'matlab' sep 'classpath.txt' ''];
Use fileparts to return the path name (including user name), file name, and file extension:
[pathstr, name, ext] = fileparts(file) pathstr = \home\user4\matlab name = classpath ext = .txt
On Windows platforms, C:\ and C: are two distinct entities, where C:\ (with backslash) is the C drive in your computer, and C: (without backslash) represents the current working directory.
filesep, fullfile, ver, verLessThan, version

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |