필터 지우기
필터 지우기

what is the use of the symbol '*' in the function named fullfile?

조회 수: 17 (최근 30일)
Manoj Murali
Manoj Murali 2012년 2월 9일
편집: Erik 2013년 10월 7일
Hi,what is the significance of the asterik symbol '*' in the following statement...
filePattern = fullfile(myFolder, '*.jpg');

채택된 답변

Walter Roberson
Walter Roberson 2012년 2월 9일
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
Manoj Murali
Manoj Murali 2012년 2월 9일
oh...thanq sir...but one more doudt....
suppose,
jpgfiles=dir(filePattern);
h=length(jpgfiles);
now..wat does the above two statements mean..??
Walter Roberson
Walter Roberson 2012년 2월 9일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Dr. Seis
Dr. Seis 2012년 2월 9일
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
  댓글 수: 1
Manoj Murali
Manoj Murali 2012년 2월 9일
oh...thanq sir...but one more doudt....
suppose,
jpgfiles=dir(filepattern);
h=length(jpgfiles);
now..wat does the above two statements mean..??

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by