dir('*.mat') returns *.mat*

dir('*.mat') returns *.mat*

Post by Brian » Wed, 08 Jun 2005 23:42:14

Is this a know issue?

dir('*.mat') returns *.mat*

I searched the groups and the support site and found no mention of it.



dir('*.mat') returns *.mat*

Post by Dan Hensle » Thu, 09 Jun 2005 00:36:10

Welcome to the world of Windows. This is an OS issue, not a Matlab issue.
I've complained about it before, but there's not much they can do.
You'll have to write code to work around this.



dir('*.mat') returns *.mat*

Post by us » Thu, 09 Jun 2005 01:43:53

<SNIP former OS related problem...

what release do you have?
r14.sp2 returns this on a typical wintel

% *.mat not found.


dir('*.mat') returns *.mat*

Post by TigerJad » Thu, 09 Jun 2005 04:31:23

I don't have this problem with Matlab 6.51 and win2k sp4.
Maybe it's OS or version specific?

dir('*.mat') returns *.mat*

Post by Steve Amph » Thu, 09 Jun 2005 05:48:16

<snip, globbing problem...

I'm not sure of the answer, but the question is clearly a globbing
issue. Putting the trivial OS of Windows to one side, most shells
glob by default. command *.xxx expands the *.xxx before execution to
a command with many arguments. However, command "*.xxx" treats the *
as an asterisk. I reckon ML's dir() function execs a single command
with a single argument (not using the shell's globbing). Bear in
mind that the folowing are all valid filenames (although some are
really hard to work with and ML may not like them):

a b.mat

dir('*.mat') returns *.mat*

Post by Kell » Thu, 09 Jun 2005 06:09:02

Steve, could you clarify a bit more for the computer-near-illiterate
like me? Were you saying that Matlab's dir function doesn't accept *
as a wildcard? Because that's certainly not the case. I just ran a
quick test, and this behavior seems to be limited specifically to the
.mat extension. I'm running Matlab 7.0.4 on Windows 2000, and I'm
seeing the following behavior:

test.m test.mat test.matstuff


test*.ma not found.

test.mat test.matstuff

Is this still a Windows issue? If so, can someone explain what is so
special about this particular extension?


dir('*.mat') returns *.mat*

Post by Tom Lan » Thu, 09 Jun 2005 06:40:18

Kelly, I believe the special thing is that it has three letters. The DOS
8.3 name has the same suffix in both cases. This is all from the DOS
prompt, not from MATLAB:

D:\Work\temp>dir *.mat

06/07/2005 05:37 PM 0 temp.mat
06/07/2005 05:37 PM 0 temp.matstuff

D:\Work\temp>dir /x *.mat

06/07/2005 05:37 PM 0 temp.mat
06/07/2005 05:37 PM 0 TEMP~1.MAT temp.matstuff

-- Tom

dir('*.mat') returns *.mat*

Post by Steve Amph » Thu, 09 Jun 2005 17:03:31

<snip, ramblings about globbing...

Sorry, I was posting from home and couldn't test. Just to clarify
what I meant by globbing though (if it's of any interest): When
programs start (in most OSs) the command string contains the program
name followed by a load of arguments. Most programs will not assume
that * is meant as a wildcard - this is normally the job of the shell
or command line interpreter. It will do the wildcard expansion for
you and pass the newly created argument list in full to the program.
To pass a * to a program (at lease in UNIX shells), you either need
to disable globbing or quote the *. E.g. in a UNIX shell, touch
"*.mat" will create a file called *.mat