what is the use of the symbol '*' in the function named fullfile?
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Manoj Murali
am 9 Feb. 2012
Bearbeitet: Erik
am 7 Okt. 2013
Hi,what is the significance of the asterik symbol '*' in the following statement...
filePattern = fullfile(myFolder, '*.jpg');
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 9 Feb. 2012
The meaning is the literal character '*' . fullfile() does not process the arguments: it just puts together a file name using the exact strings you pass in. You could pass in nonsense strings and it wouldn't care.
Now, the function that you pass the completed string to might care. The context suggests the string is probably being passed to the dir() function. dir() would pass the string to the operating system, which would interpret it in operating-system specific ways. Usually '*' is interpreted as a "wildcard" meaning "any number of any characters, but excluding the directory separator". In unix systems, the "null character" (decimal value 0) is also excluded.
2 Kommentare
Walter Roberson
am 9 Feb. 2012
dir() returns a structure of information about the files or directories found. See the documentation for dir() for details.
length() of the result of dir() is the number of files or directories found.
Weitere Antworten (1)
Dr. Seis
am 9 Feb. 2012
It means that any file whose name is something.jpg will be used. For example if:
myFolder = '/home/yourfolder';
then
filePattern = fullfile(myFolder,'*.jpg');
will return
filePattern =
'/home/yourfolder/*.jpg'
An then
>> dir(filePattern)
might return something like:
pic001.jpg
pic002.jpg
pic003.jpg
pic004.jpg
Siehe auch
Kategorien
Mehr zu File Operations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!