Can't create/open txt files
Show older comments
The title pretty much sums it up. I want to use fopen to create or open a file and it is just returning -1 everytime. It seems like Matlab has not the rights to do that but I don't understand why.
I am administrator, I tried running Matlab as admistrator and I know I am in the right folder.
9 Comments
dpb
on 18 Feb 2021
Return the option message argument to see what the error returned is...and show us code/error messages in context, don't just describe to us. May be overlooking some clue.
What happens for trying to edit/save a file in editor or writing a file with, say, writematrix that just takes a filename? Do they fail as well?
Theo Y
on 18 Feb 2021
dpb
on 18 Feb 2021
"What happens for trying to edit/save a file in editor or writing a file with, say, writematrix that just takes a filename? Do they fail as well?"
Out of curiosity, what does
cd
return?
Theo Y
on 18 Feb 2021
dpb
on 18 Feb 2021
What about
!attrib D:\Work
!attrib D:\Work\Stage
??
Theo Y
on 18 Feb 2021
Theo Y
on 18 Feb 2021
dpb
on 18 Feb 2021
Indeed, looks strange.
wd='D:\Work\Stage';
[stuff,msg] = fopen(fullfile(wd,'filename.txt'),'w')
??
Theo Y
on 18 Feb 2021
Accepted Answer
More Answers (0)
Categories
Find more on Data Import and Export in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!