uigetfile()的用法:标准打开文件对话窗口
1.[FILENAME, PATHNAME, FILTERINDEX] = uigetfile(FILTERSPEC, TITLE)
example:
[filename, pathname, filterindex] = uigetfile('*.m', 'Pick a MATLAB code file');
[filename, pathname, filterindex] = uigetfile( ...
{'*.m;*.fig;*.mat;*.mdl', 'All MATLAB Files (*.m, *.fig, *.mat, *.mdl)';
'*.m', 'MATLAB Code (*.m)'; ...
'*.fig','Figures (*.fig)'; ...
'*.mat','MAT-files (*.mat)'; ...
'*.mdl','Models (*.mdl)'; ...
'*.*', 'All Files (*.*)'}, ...
'Pick a file');
2.[FILENAME, PATHNAME, FILTERINDEX] = uigetfile(FILTERSPEC, TITLE, FILE);
输出变量:【FileName:文件名称 ; PathName:返回的文件的路径名 ;FilterIndex: 返回在对话框中选择的过滤器的索引值(1或0(中途取消))】
输入变量:【FilterSpec:文件类型设置;TITLE:对话框的标题名称;FILE:一个字符串,包含用作默认选择指向的名称】
EXAMPLE:
[FileName,PathName,FilterIndex]=uigetfile('*.txt;*.mat','Select the file','C:\Users\Diannie\Documents');
if isequal(FileName,0) || isequal(PathName,0)
disp('User pressed cancel')
else
disp(['User selected ', fullfile(PathName, FileName)])
end
TestData=load(fullfile(PathName,FileName));