matlab中的folder,科学网—Matlab: list folder contents - 刘洋洋的博文

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值