开发者

Why matlab does not understand * in the names of files?

I tried to use:

dir('dirname\*')

and it did not work. It sta开发者_JAVA百科rted to work after I started to use:

dir('dirname\m*')

Does anybody know why?


Matlab does understand wildcards *, but in the way you unluckiliy tried to adhere to Windows cmd path conventions, you entered the string \*, which is a literal asterisk (due to the escaping backslash).

A workaround, or the preferred way to specify paths on all platforms, is using a forward slash / as a directory seperator.

dir('dirname/*')

This also explains why adding the m after the backslash "fixed" the issue; the asterisk was no longer a literal asterisk, but allowed to be interpreted as a wildcard character.

EDIT: Documentation explicitely says the wildcard character is allowed and works as expected (see my explanation above).


Try to provide the full path, like dir('c:\dirname*.m'), and make sure the folder 'dirname' exists.


What is your OS ? Here on Windows, the first line works well. However, the "*" is maybe considered by Matlab as a literal "*". What happens with dir('dirname/*') ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜