MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   Matlab'exist'对于肯定存在的文件返回0! (https://www.labfans.com/bbs/showthread.php?t=23997)

poster 2019-12-10 20:48

Matlab'exist'对于肯定存在的文件返回0!
 
我正在Windows下运行Matlab 7.8.0。

我正在使用dos()调用外部实用程序,该实用程序会在当前目录中创建一个文件。我已经正确创建了文件,但是exist或fopen无法看到它,它们分别返回0和-1 。文件名正确!

>> pwd ans = I:\ >> ls file1.asc file2.asc file3.asc >> exist('file1.asc') % this file was there before ans = 2 >> exist('file2.asc') % this file is newly created ans = 0 为了确认它不是奇数/问题文件名,我从Cygwin shell中进行了检查:

/cygdrive/i/ $ if [ -f file2.asc ]; then echo "OK"; fi OK 因此文件很好。我试图重命名

/cygdrive/i/ $ mv file2.asc test 在Matlab中

>> ls file1.asc file3.asc test >> exist('test') ans = 0 如果我退出并重新启动Matlab,它可以正常工作。但是我需要动态创建文件然后访问它!



[B]回答:[/B]

很神秘

您可以尝试:
[LIST][*] [B]rehash[/B]命令以查看是否有帮助。[*]存在的两个参数的版本: [B]exist('foo.txt','file')[/B][/LIST]
[url=https://stackoverflow.com/questions/3938687]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 23:24

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.