...
> I am running windows, and that "?" wildcard would certainly be what I
> would like to use, just to try and keep things simple. Although it
> does not seem to work. Is there something special about MATLAB R14
> Student Version that would not allow "?" to work as a wildcard?
No, it's a bug and has been around since at least Ver 5.3 (oldest I have
loaded). The Matlab dir() function isn't treating the "?" as a wildcard
character on Windows and passing it to the OS.
However, you can work around it in the following way...
>> dir('c:\temp\f*.dat')
f123.dat f123_spec.dat f124.dat f124_spec.dat
(Demonstrates what's in c:\temp of interest)
>> [stat,d]=dos('dir /b c:\temp\f???.dat')
stat =
0
d =
f123.dat
f124.dat
--
M@ - 17 Jul 2008 20:59 GMT
> ...
>
[quoted text clipped - 23 lines]
>
> --
this code turns the file names to character, as opposed to strings.
i.e. d(1)=f as opposed to the more useful d(1)= 'f123.dat'
I'm sure there are many ways of getting characters back to strings,
and i'm sorry for the hand-holding approach to coding i'm taking. I'm
just the closest thing this lab has to a programmer, and thus the
burden was laid. =P
dpb - 17 Jul 2008 23:31 GMT
...
>> [stat,d]=dos('dir /b c:\temp\f???.dat')
>> stat =
>> 0
>> d =
>> f123.dat
>> f124.dat
...
> this code turns the file names to character, as opposed to strings.
> i.e. d(1)=f as opposed to the more useful d(1)= 'f123.dat'
[quoted text clipped - 3 lines]
> just the closest thing this lab has to a programmer, and thus the
> burden was laid. =P
I admit I didn't do anything but make sure the dos() function did end up
w/ the OS "doing the right thing" so only saw the displayed output was
the correct file names, not how they were returned.
Turns out the names are terminated by lf character (ASCII decimal 10) so
strtok() will work to return each filename from the array.
Try something like
r=d;while length(r)>1, [f,r]=strtok(r), end
Normally would like the while condition to be something like ~isempty(r)
but in this case there's a lf after the last filename also and the
remainder of the string after the token is returned also contains the
terminating token.
Alternatively, know that, one could also be clever as the following shows...
>> r=d;while ~isempty(r), [f,r]=strtok(r); r=r(2:end); disp(f), end
f123.dat
f124.dat
dpb - 17 Jul 2008 23:38 GMT
...
> No, it's a bug and has been around since at least Ver 5.3 (oldest I have
> loaded). The Matlab dir() function isn't treating the "?" as a wildcard
> character on Windows and passing it to the OS.
...
Well, that's not really stated correctly -- it appears of course that
the "?" does get passed to the OS, but somehow the API used doesn't
honor it. Interestingly, to see if there was something funky in the
Win32 API, I tried the VB Dir$ function and it does honor it. So,
either VB does a fixup or there's something not kosher about the Matlab
call...wherever it actually is, it's a bug as the routine doesn't behave
properly for the underlying OS...
I don't think it had ever been anything I had noticed in Matlab prior to
now, though... :)
--
dpb - 18 Jul 2008 19:16 GMT
> ...
>> No, it's a bug and has been around since at least Ver 5.3 (oldest I
>> have loaded). The Matlab dir() function isn't treating the "?" as a
>> wildcard character on Windows and passing it to the OS.
...
> I don't think it had ever been anything I had noticed in Matlab prior to
> now, though... :)
It doesn't show as a currently listed but so I reported the anomalous
behavior as a bug...
--