%%THD SNR PSD
clear all
close all
clc


[file,path]=uigetfile('*.txt','请选择要处理的文件:');
if isequal(file,0)
disp('User selected Cancel');
else
disp(['User selected ', fullfile(path,file)]);
end
dat=load ([path file]);

显示筛选器索引选择

在命令行窗口中显示选定筛选器的索引及相关的说明性文本。使用 num2str 函数将数值型筛选器索引值 (indx) 转换为字符数组。这样可使索引值成为 disp 函数的有效输入。

[file,path,indx] = uigetfile;
if isequal(file,0)
disp('User selected Cancel')
else
disp(['User selected ', fullfile(path, file),...
' and filter index: ', num2str(indx)])
end

matlab 可选择读取文件_命令行

User selected H:\Documents\MyCode\peaks.fig and filter index: 3

文章参考:https://ww2.mathworks.cn/help/matlab/ref/uigetfile.html?searchHighlight=uigetfile&s_tid=srchtitle