Wednesday, April 1, 2015

[MATLAB] How to get the file name without extension, 파일 이름, 확장자 분리

MATLAB R2012b version

Syntax

[pathstr, name, ext] = fileparts(filename)

Output Arguments

pathstrThe path of the file
nameThe file name without extension
extThe file extension, beginning with a period (.)

Examples

file = 'C:\filepath\filename.txt';
[pathstr, name, ext] = fileparts(file)

pathstr =
C:\filepath

name =
filename

ext =
.txt
=====================================
file = '\filepath\.txt';
[pathstr, name, ext] = fileparts(file)

pathstr =
\filepath

name =
   Empty string: 1-by-0

ext =
.txt

No comments:

Post a Comment