How can I use wildcard '*' in both the folder name and file name when using DIR in MATLAB 7.9 (R2009b)?

48 次查看(过去 30 天)
Under UNIX, the following works :
>> ls (fullfile(matlabroot, 'toolbox/matlab/audio*/*.m'))
But DIR does not support wildcard in both the folder and the file name :
>> dir ('C:/WORK/MATLAB_WORK/M*')
MATHS MCC MEX ML MLCentral MPC555 Mapping MyProject
>> dir ('C:/WORK/MATLAB_WORK/ML/*.m')
datenum_6b.m test.m
largest_memory_block_available.m
>> dir ('C:/WORK/MATLAB_WORK/M*/*.m')
C:\WORK\MATLAB_WORK\M*\*.m not found.

采纳的回答

MathWorks Support Team
The ability to use DIR with wildcard (*) in both the folder and the path name is not available in MATLAB 7.9 (R2009b).
To work around this issue, you can write your own function which will act as follow :
list_dir = dir('/appli/matlab/r2008b/toolbox/matlab/graph*');
for i = 1:length(list_dir)
list_files = dir(['/appli/matlab/r2008b/toolbox/matlab/' list_dir(i).name '/*.m']);
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

标签

尚未输入任何标签。

产品


版本

R2009b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by