List all the files and folders in the current directory
Syntax: dir
或者 dir('.')
List the contents of a folder
Syntax: dir VIP_1 % VIP_1 is the name of a folder contained in the current working directory.
dir /Volumes/DATA/VIP_1/ % the path of the folder VIP_1.
List all the dat files in the current folder
Syntax: dir *.dat
或者 dir('*.dat')
List all the txt files that contain the term acs (the files and folders in VIP_1) with 5 fields in a structure array:
Syntax: FileInfo=dir *acs*.txt
FolderInfo=dir VIP_1
Output:
name % file or folder name --character vector
date % modification date timestamp --character vector
bytes % size of the file in bytes --double vector
isdir % if name is a directory, 1--True, 0--False --logical vector
datenum % modification date as serial date number --double vector
Get a field of a file.
Syntax: ACsFile=dir acs01.dat;
FileName=ACsFile.datenum; % get the datenum field of the file structure array.
!DO NOT use the datenum function to convert the string returned in the date field of the structure to a number. The results of the datenum function vary depending on the locale. Instead, use the datenum field.
转载本文请联系原作者获取授权,同时请注明本文来自刘洋洋科学网博客。
链接地址:http://blog.sciencenet.cn/blog-3031432-997273.html
上一篇:Matlab: concatenate two strings
下一篇:Matlab: input & fprintf