fopen only returns -1
27 次查看(过去 30 天)
显示 更早的评论
Hi,
I'm trying to read some files (wave-files, but I also tried text) with fopen, but it always returns -1, ie. there is an error. It worked fine when selecting a .m-file. What am I forgetting? I use
fopen(uigetfile)
Edit:
It seems to have to do with the uigetfile. When I enter the path directly, it works fine. However, I don't understand, why, since I do select the specific path with uigetfile, don't I?
0 个评论
采纳的回答
Walter Roberson
2016-4-15
[filename, filepath] = uigetfile();
fullname = fullfile(filepath, filename);
fid = fopen(fullname);
Your version would only have been getting the file without its directory. When you use the single output version of uigetfile, uigetfile does not output the fully-qualified name.
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!