Using filepath input in fopen
Mostrar comentarios más antiguos
Hi all, I can't seem to use fopen to open a file using a variable that stores the name and path of the file. For example, the variable [pathvariable] stores /imper/codec/data.txt. I am doing fid = fopen([pathvariable],'r') but it is not working.
I've tried the following too:
fid = fopen(pathvariable,'r')
fid = fopen('pathvariable','r')
In all cases, I get a fid of -1.
Could someone please help. Thanks.
3 comentarios
KSSV
el 17 de Ag. de 2017
How did you provide pathvariable? Check whether the file is present or not with exist.
Stephen23
el 17 de Ag. de 2017
@Suha: in 99 percent of cases the filepath is incorrect or there is a spelling mistake somewhere. Check the filename carefully.
Suha
el 17 de Ag. de 2017
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Entering Commands en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!