Matlab中文件检索对话框

2025-11-04 14:15:57

1、Matlab中文件检索对话框命令为uigetfile。

主要用法为[file, filename] = uigetfile('.');

前面中括号中为文件名称和文件的绝对路径,后面的括号需要指定文件的类型。

具体用法如下:

2、先介绍常用的方法:

filename = uigetfile('*.txt');

只获取当前文件夹中的txt文件,无法获取其他文件,如果要显示所有文件,可以使用如下命令:

filename = uigetfile('*.*');

filename的返回值:

filename =aa.txt

Matlab中文件检索对话框

Matlab中文件检索对话框

3、这里只是给出了当前文件夹下的内容,但如果要打开其他文件夹的内容:

[filename,pathname] = uigetfile('*.png')

返回值为:

filename =2016-10-07 10-53-31屏幕截图.pngpathname =/home/zwl/图片/Matlab中值滤波和smooth/

Matlab中文件检索对话框

4、这里只能返回一个文件,如果要打开多个文件,则需要:

[filename,pathname] = uigetfile('*.png','multiselect','on')

返回:

filename =   Columns 1 through 2    '2016-10-01 16-32-…'    '2016-10-01 16-33-…'  Columns 3 through 4    '2016-10-01 16-35-…'    '2016-10-01 16-42-…'  Columns 5 through 6    '2016-10-01 16-54-…'    '2016-10-01 16-56-…'pathname =/home/zwl/图片/matlab一维插值/

Matlab中文件检索对话框

5、也可以在对话框中提取其他文件的数据,如下图所示。

Matlab中文件检索对话框

6、这样就可以选择打开文件,比如要逐行读取文件:

fid = fopen(filename,'r');

tline = fgetl(fid);

while feof(fid)==0

tline = fgetl(fid);

end

Matlab中文件检索对话框

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢