haibaraxx的个人博客分享 http://blog.sciencenet.cn/u/haibaraxx

博文

Matlab: list folder contents

已有 2498 次阅读 2016-8-18 17:50 |个人分类:Matlab|系统分类:科研笔记| list, Contents, folder

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.



https://blog.sciencenet.cn/blog-3031432-997273.html

上一篇:Matlab: concatenate two strings
下一篇:Matlab: input & fprintf
收藏 IP: 134.1.1.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-10-20 04:49

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部