wildcard in dir command - single char

how can i search files of pattern aaa0.... aaa1......
without finding the file aaa (without number)
at system dir command its " dir aaa? "
but i cant run this in matlab
i need the results as structure so i cant use system command

Antworten (1)

Stephen23
Stephen23 am 23 Jul. 2019
Bearbeitet: Stephen23 am 23 Jul. 2019

0 Stimmen

dir does not support single-character wildcards.
You could remove the superfluous filenames afterwards, e.g.:
>> S = dir('aaa*.txt');
>> S.name
ans = aaa.txt
ans = aaa0.txt
ans = aaa1.txt
>> C = {S.name};
>> X = cellfun('isempty',regexp(C,'^aaa\d.txt$'));
>> S = S(~X);
>> S.name
ans = aaa0.txt
ans = aaa1.txt

4 Kommentare

Anil Thota
Anil Thota am 4 Feb. 2020
Hi,
I was able to use dir(['dddd\*_X??']) for listing all the directories ending _Xnn. Strangely, I am not able to use the same command in my laptop. Both the matlab versions are 2018a. I wonder why?
Best,
Anil
Walter Roberson
Walter Roberson am 4 Feb. 2020
Are they the same operating system?
Anil Thota
Anil Thota am 30 Sep. 2020
Yes - Same Operating system. What is the wild character for specifying one character?
Thank you,
Anil
Walter Roberson
Walter Roberson am 30 Sep. 2020
The Mathworks documentation says that wildcards for single characters is not supported.

Melden Sie sich an, um zu kommentieren.

Kategorien

Produkte

Version

R2019a

Gefragt:

am 23 Jul. 2019

Kommentiert:

am 30 Sep. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by