fopen only returns -1

20 visualizaciones (últimos 30 días)
Anke Kügler
Anke Kügler el 15 de Abr. de 2016
Respondida: Anke Kügler el 16 de Abr. de 2016
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?

Respuesta aceptada

Walter Roberson
Walter Roberson el 15 de Abr. de 2016
[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.

Más respuestas (1)

Anke Kügler
Anke Kügler el 16 de Abr. de 2016
Thank you! I was kinda suspecting something like this, but didn't know how to fix it. Your code works.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by